打印队列 (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 ...
随机推荐
- OpenMax的接口与实现
OpenMax IL层的接口定义由若干个头文件组成,这也是实现它需要实现的内容,它们的基本描述如下所示. OMX_Types.h:OpenMax Il的数据类型定义 OMX_Core.h:OpenMa ...
- TCP Three-way Handshake
TCP Connection Management Out-of-Order and Duplication(复制) Problem Old segment from previous connect ...
- SecureCRT连接主机时(串口/网络),无法从键盘输入
Session Option-Connection-Serial-Flow Control,里面的选项全部取消掉,再重启CRT就ok了...
- MyBatis之Mapper XML 文件详解(一)
MyBatis 的真正强大在于它的映射语句,也是它的魔力所在.由于它的异常强大,映射器的 XML 文件就显得相对简单.如果拿它跟具有相同功能的 JDBC 代码进行对比,你会立即发现省掉了将近 95% ...
- 五、MapReduce 发布服务
是一个并行计算框架(计算的数据源比较广泛-HDFS.RDBMS.NoSQL),Hadoop的 MR模块充分利用了HDFS中所有数据节点(datanode)所在机器的内存.CUP以及少量磁盘完成对大数据 ...
- 自动化运维工具Ansible实战(四)常用模块
转载链接:http://blog.51cto.com/liqingbiao/1962609 Ansible模块按功能分为:云模块.集群模块. 命令模块.数据库模块.文件模块.资产模块.消息模块.监 ...
- Flask—09-项目部署(01)
项目部署 WEB工作原理 客户端(chrom) <=> WEB服务器(nginx) <=> WSGI(uWSGI) <=> Python(Flask) <=& ...
- node的安装和配置
一 . 直接安装node 1. http://nodejs.cn/download/ 根据自己的电脑选择适合的安装包 2.安装 , 无脑下一步 , 可以选择安装路径 , 但是一定要记住 . 3.命令行 ...
- Jquery中数值求和及根据余数改变对应的数值样式
Jquery内容 <script type="text/javascript"> $(function () { var num = 0; $(".box o ...
- Python-调用系统指令小记
import subprocess def exec_command(cmd, log_path, **kwargs): with open(log_path, 'w') as f: p = subp ...