打印队列 (Printer Queue,ACM/ICPC NWERC 2006,UVA12100)
题目描述:

题目思路:
使用一个队列记录数字,一个优先队列记录优先级,如果相等即可打印;
#include <iostream>
#include <queue>
using namespace std;
int main(int argc, char *argv[])
{
int t;
cin >> t;
while(t--)
{
int n,pos;
queue<int> q ;
priority_queue<int> pq ;
cin >> n >> pos ;
for(int i=;i<n;i++)
{
int a;
cin >> a;
q.push(a);
pq.push(a);
}
int t = ;
while(true)
{
if(q.front() == pq.top())
{
if(t==pos){cout<<n-q.size()+<<endl;break;}
else{
q.pop();
pq.pop();
t++;
}
}
else{
int temp = q.front();
q.pop();
q.push(temp);
if(t == pos){t=;pos=q.size()-;}
else t++ ; }
}
}
return ;
}
打印队列 (Printer Queue,ACM/ICPC NWERC 2006,UVA12100)的更多相关文章
- 集合栈计算机(The SetStack Computer, ACM/ICPC NWERC 2006,Uva12096)
集合栈计算机(The SetStack Computer, ACM/ICPC NWERC 2006,Uva12096) 题目描述 有一个专门为了集合运算而设计的"集合栈"计算机.该 ...
- 集合栈计算机 (The SetStack Computer,ACM/ICPC NWERC 2006,UVa12096
题目描述: #include<iostream> #include<string> #include<set> #include<map> #inclu ...
- ACM程序设计选修课——1044: (ds:队列)打印队列(queue模拟)
问题 A: (ds:队列)打印队列 时间限制: 1 Sec 内存限制: 128 MB 提交: 25 解决: 4 [提交][状态][讨论版] 题目描述 网络工程实验室只有一台打印机,它承担了非常繁重 ...
- DNA序列 (DNA Consensus String,ACM/ICPC Seoul 2006,UVa1368
题目描述:算法竞赛入门经典习题3-7 题目思路:每列出现最多的距离即最短 #include <stdio.h> #include <string.h> int main(int ...
- 换抵挡装置 (Kickdown,ACM/ICPC NEERC 2006,UVa1588
题目描述:算法竞赛入门经典习题3-11 题目思路:1.两长条移动匹配 2.上下调换,取小者 #include <stdio.h> #include <string.h> int ...
- UVa 12100 Printer Queue(queue或者vector模拟队列)
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 ...
- hduoj 4712 Hamming Distance 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Other ...
- Printer Queue
Description The only printer in the computer science students' union is experiencing an extremely he ...
随机推荐
- Many-to-many relationships in EF Core 2.0 – Part 4: A more general abstraction
In the last few posts we saw how to hide use of the join entity from two entities with a many-to-man ...
- oracle本地安装注意事项
这两天组员在本地windows上安装oracle数据库,安装完各种问题,pl/sql developer以及tns_admin配置以及tnsnames.ora和sqlnet.ora listener. ...
- iOS:绘图(18-01-25更)
目录 1.UIBezierPath(贝塞尔曲线) 1).在重写 drawRect: 方法里使用 2).在普通方法里使用,需要画布. 3). 切圆角.指定位置圆角.任意形状. 4).彩色的动画加载圆圈. ...
- SQL:登录、连接数据库基本操作
使用MySQL 登录.连接数据库 win+R打开控制台,cmd进入控制台,输入mysql -u root -p,后输入密码,进入数据库: 首先可以查看原有的数据库,输入 show databases; ...
- 07.安装及使用gitlub
博客为日常工作学习积累总结: 1.安装gitlub sudo yum install -y curl policycoreutils-python openssh-server openssh-cli ...
- 06.升级git版本及命令学习
博客为日常工作学习积累总结: 1.升级git版本: 参考博客:https://blog.csdn.net/yuexiahunone/article/details/78647565由于新的版本可以使用 ...
- ES6 imports用法
import defaultExport from "module-name"; import * as name from "module-name"; // ...
- django的验证码
pip install Pillow==3.4.1在views.py中创建一个视图函数 from PIL import Image, ImageDraw, ImageFont from django. ...
- N对数的排列问题 HDU - 2554
N对数的排列问题 HDU - 2554 有N对双胞胎,他们的年龄分别是1,2,3,……,N岁,他们手拉手排成一队到野外去玩,要经过一根独木桥,为了安全起见,要求年龄大的和年龄小的排在一起,好让年龄大的 ...
- HyperLedger Fabric 1.4 kafka生产环境部署(11.1)
11.1 Kafka模式简介 上一章介绍的Solo模式只存在一个排序(orderer)服务,是一种中心化结构,一旦排序(orderer)服务出现了问题,整个区块链网络将会崩溃,为了能在正式 ...