题目

题目

 


 

分析

练习STL

 


 

代码

#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,m,a[105],cnt=0;
queue <int> que;
priority_queue <int> Big;
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++) que.push(i);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
Big.push(a[i]);
}
for(;;)
{
int x=que.front();
if(a[x]==Big.top())
{
que.pop();Big.pop();
cnt++;
if(x==m) break;
}
else
{
que.pop();que.push(x);
}
}
printf("%d\n",cnt);
}
return 0;
}

【UVA】12100 Printer Queue(STL队列&优先队列)的更多相关文章

  1. uva 12100 Printer Queue 优先级队列模拟题 数组模拟队列

    题目很简单,给一个队列以及文件的位置,然后一个一个检查,如果第一个是优先级最高的就打印,否则放到队列后面,求所要打印的文件打印需要花费多长时间. 这里我用数组模拟队列实现,考虑到最糟糕的情况,必须把数 ...

  2. UVa 12100 Printer Queue(queue或者vector模拟队列)

    The only printer in the computer science students' union is experiencing an extremely heavy workload ...

  3. uva 12100 Printer Queue

    The only printer in the computer science students' union is experiencing an extremely heavy workload ...

  4. UVa 12100 Printer Queue (习题 5-7)

    传送门:https://uva.onlinejudge.org/external/121/12100.pdf 题意:队列中待打印的任务(1 <= n <= 100)带有优先级(1-9), ...

  5. 12100 Printer Queue(优先队列)

    12100 Printer Queue12 The only printer in the computer science students’ union is experiencing an ex ...

  6. Printer Queue UVA - 12100

    The only printer in the computer science students' union is experiencing an extremely heavy workload ...

  7. J - Printer Queue 优先队列与队列

    来源poj3125 The only printer in the computer science students' union is experiencing an extremely heav ...

  8. C/C++解题常用STL大礼包 含vector,map,set,queue(含优先队列) ,stack的常用用法

    每次忘记都去查,真难啊 /* C/C++解题常用STL大礼包 含vector,map,set,queue(含优先队列) ,stack的常用用法 */ /* vector常用用法 */ //头文件 #i ...

  9. UVA.540 Team Queue (队列)

    UVA.540 Team Queue (队列) 题意分析 有t个团队正在排队,每次来一个新人的时候,他可以插入到他最后一个队友的身后,如果没有他的队友,那么他只能插入到队伍的最后.题目中包含以下操作: ...

随机推荐

  1. keras 报错 ValueError: Tensor conversion requested dtype int32 for Tensor with dtype float32: 'Tensor("embedding_1/random_uniform:0", shape=(5001, 128), dtype=float32)'

    在服务器上训练并保存模型,复制到本地之后load_model()报错: ValueError: Tensor conversion requested dtype int32 for Tensor w ...

  2. asp.net Npoi 使用

    HSSFWorkbook hssfworkbook = new HSSFWorkbook(); //增加 ExcelNPOI.SS.UserModel.ISheet SheetName = hssfw ...

  3. Aria2 - OS X 下载百度云资源神器

    官网介绍: (Aria2 is a light weight multi-protocol & multi-source command-line download utility. It s ...

  4. asp.net 输入框在chrome中无法关闭自动提示

    将asp:TextBox 的属性AutoCompleteType设为Disabled,希望在chrome中点击记住用户名密码后输入框不再自动提示,但不起作用. 解决方法: <asp:TextBo ...

  5. Postfix常用命令和邮件队列管理(queue)

    本文主要介绍一下postfix的常用命令及邮件队列的管理: Postfix有以下四种邮件队列,均由管理队列的进程统一进行管理: maildrop:本地邮件放置在maildrop中,同时也被拷贝到inc ...

  6. cocos2d-x 发布win32 release版本后找不到msvcr110.dll

    解决方法: 安装Visual C++ Redistributable for Visual Studio 2012 //下载地址 http://www.microsoft.com/zh-CN/down ...

  7. HDU2222 Keywords Search ac自动机第一题

    指针我一般都会出错,所以还是自己写数组版本. In the modern time, Search engine came into the life of everybody like Google ...

  8. hiho1613 墨水滴

    对不起,太弱了.................想了一下午

  9. Eclipse中注释方法操作(两种)

    Eclipse 中的两种注释方法:(1)多行注释 /* */ (2)单行注释 // 多行注释操作方法. 选中注释部分-菜单栏右上角 source: Add block comment.必须选中需要注释 ...

  10. BZOJ2120 数颜色 【带修莫队】

    BZOJ2120 数颜色 Description 墨墨购买了一套N支彩色画笔(其中有些颜色可能相同),摆成一排,你需要回答墨墨的提问.墨墨会像你发布如下指令: 1. Q L R代表询问你从第L支画笔到 ...