【UVA】12100 Printer Queue(STL队列&优先队列)
题目
分析
练习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队列&优先队列)的更多相关文章
- uva 12100 Printer Queue 优先级队列模拟题 数组模拟队列
题目很简单,给一个队列以及文件的位置,然后一个一个检查,如果第一个是优先级最高的就打印,否则放到队列后面,求所要打印的文件打印需要花费多长时间. 这里我用数组模拟队列实现,考虑到最糟糕的情况,必须把数 ...
- UVa 12100 Printer Queue(queue或者vector模拟队列)
The only printer in the computer science students' union is experiencing an extremely heavy workload ...
- uva 12100 Printer Queue
The only printer in the computer science students' union is experiencing an extremely heavy workload ...
- UVa 12100 Printer Queue (习题 5-7)
传送门:https://uva.onlinejudge.org/external/121/12100.pdf 题意:队列中待打印的任务(1 <= n <= 100)带有优先级(1-9), ...
- 12100 Printer Queue(优先队列)
12100 Printer Queue12 The only printer in the computer science students’ union is experiencing an ex ...
- Printer Queue UVA - 12100
The only printer in the computer science students' union is experiencing an extremely heavy workload ...
- J - Printer Queue 优先队列与队列
来源poj3125 The only printer in the computer science students' union is experiencing an extremely heav ...
- C/C++解题常用STL大礼包 含vector,map,set,queue(含优先队列) ,stack的常用用法
每次忘记都去查,真难啊 /* C/C++解题常用STL大礼包 含vector,map,set,queue(含优先队列) ,stack的常用用法 */ /* vector常用用法 */ //头文件 #i ...
- UVA.540 Team Queue (队列)
UVA.540 Team Queue (队列) 题意分析 有t个团队正在排队,每次来一个新人的时候,他可以插入到他最后一个队友的身后,如果没有他的队友,那么他只能插入到队伍的最后.题目中包含以下操作: ...
随机推荐
- PostgreSQL 系统参数调整及并行设置(转)
转自:https://yq.aliyun.com/teams/5 OS 准备 # yum -y install coreutils glib2 lrzsz sysstat e4fsprogs xfsp ...
- linux配置PHP环境!!(云服务器架设)
首先去阿里云或腾讯云购买主机(腾讯云现在有免费30天的云主机...) 购买好之后选择安装: 点登陆 就可以到linux的操作界面了 进入操作界面 输入root账号密码取得权限之后就可以开始配置环境了 ...
- 深度学习(六十八)darknet使用
这几天因为要对yolo进行重新训练,需要用到imagenet pretrain,由于网络是自己设计的网络,所以需要先在darknet上训练imagenet,由于网上都没有相关的说明教程,特别是图片路径 ...
- IOS开发GCD小结
0. Brief Introduction GCD,全称Grand Central Dispath,是苹果开发的一种支持并行操作的机制.它的主要部件是一个FIFO队列和一个线程池,前者用来添加任务,后 ...
- VSS虚拟交换系统
下面介绍一下如何在CISCO交换机上配置VSS,具体配置如下: //在CISCO1 上配置vss域,两台设备都要在同一个域中 Cisco-(confgi)#switch virtual domain ...
- IOS 的本地通知
IOS 的本地通知 - (void)viewDidLoad { [super viewDidLoad]; UILocalNotification* localNotification = [[UILo ...
- HihoCoder1050 树中的最长路 树形DP第三题(找不到对象)
题意:求出的树中距离最远的两个结点之间相隔的距离. 水题一道,以前只会用路的直径来解. 代码如下: #include<cstdio> #include<cstdlib> #in ...
- Uoj 22 外星人
Uoj 22 外星人 注意到一个数只有 \(\%\) 了小于等于自己的数时,才可能有变化,否则可以随意安排,不会对最后最优解造成影响. 用 \(f[x]\) 表示给一个数 \(x\) ,仅用 \(a[ ...
- BZOJ1183 Croatian2008 Umnozak 【数位DP】*
BZOJ1183 Croatian2008 Umnozak Description 定义一个数的digit-product是它的各个位上的数字的乘积,定义一个数的self-product是它本身乘以它 ...
- Orders
The stores manager has sorted all kinds of goods in an alphabetical order of their labels. All the k ...