【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个团队正在排队,每次来一个新人的时候,他可以插入到他最后一个队友的身后,如果没有他的队友,那么他只能插入到队伍的最后.题目中包含以下操作: ...
随机推荐
- vue.js 源代码学习笔记 ----- instance state
/* @flow */ import Dep from '../observer/dep' import Watcher from '../observer/watcher' import { set ...
- SAPUI5实例一:来创建Web应用UI
试试SAPUI5.这是SAP比较重要的一个UI库.完全通过HTML5实现,可以作为Web和移动应用的UI开发. 现在已经开源了.在这里可以下载: http://sap.github.io/openui ...
- 关于Objective-C 2.0 的垃圾收集
Objective-C 2.0最大的增强可能就是垃圾收集了(Garbage Collection).与“垃圾收集”对应的是传统的引用计数(Reference Count)内存管理形式. 使用了垃圾 ...
- Underscore template
/********************************************************************* * Underscore template * 说明: * ...
- hiho1523 数组重排2
时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 给定一个1-N的排列A1, A2, ... AN,每次操作小Hi可以选择一个数,把它放到数组的最左边. 请计算小Hi最少进 ...
- JS实现浏览器打印、打印预览
1.JS实现打印的方式方式一:window.print()window.print();会弹出打印对话框,打印的是window.document.body.innerHTML中的内容,下面是从网上摘到 ...
- BootStrap FileInput 插件实现多文件上传前端功能
<!DOCTYPE html> <html> <head> <title>文件上传</title> <meta charset=&qu ...
- BZOJ3688 折线统计【树状数组优化DP】
Description 二维平面上有n个点(xi, yi),现在这些点中取若干点构成一个集合S,对它们按照x坐标排序,顺次连接,将会构成一些连续上升.下降的折线,设其数量为f(S).如下图中,1-&g ...
- BZOJ1816 Cqoi2010 扑克牌【二分答案】
BZOJ1816 Cqoi2010 扑克牌 Description 你有n种牌,第i种牌的数目为ci.另外有一种特殊的牌:joker,它的数目是m.你可以用每种牌各一张来组成一套牌,也可以用一张jok ...
- .NET Core 和 .NET Framework 中的 MEF2
MEF,Managed Extensibility Framework,现在已经发布了三个版本了,它们是 MEF 和 MEF2. 等等!3 去哪儿了?本文将教大家完成基于 MEF2 的开发. ME ...