关于“打印队列 Printer Queue, ACM/ICPC NWERC 2006, UVa 12100)"的讨论
来源:互联网 发布:大数据时代来了视频 编辑:程序博客网 时间:2024/05/18 02:48
打印队列有两个属性,一个是优先级一个是位置,可以写一个结构体存储这些信息再利用queue的特性完成本题
#include<iostream>#include<queue>#include<vector>using namespace std;const int maxn = 100;struct Coor{int priority;int position;} co[maxn];queue<Coor> line;void main(){int n;int a;cin >> n;for(int i = 0; i < n; i++){cin >> a;co[i].priority = a;co[i].position = i;line.push(co[i]);}int positon;cin >> positon;int max = 0;bool is_print = false;int count = 0;while(!is_print){if(max == 0){for(int i = 0; i < n; i++){if(co[i].priority != 0){if(max < co[i].priority) max = co[i].priority;}}}Coor co1 = line.front();if(co1.priority == max){if(co1.position == positon){count++;is_print = true;}else{co[co1.position].priority = 0;max = 0;line.pop();count++;}}else{line.pop();line.push(co1);}}cout << count << endl;}
0 0
- 关于“打印队列 Printer Queue, ACM/ICPC NWERC 2006, UVa 12100)"的讨论
- Printer Queue 打印队列 UVA 12100
- uva 12100 Printer Queue(打印队列)模拟
- 5-7 UVA 12100 Printer Queue打印队列
- Printer Queue打印队列
- 打印队列(Printer Queue)
- UVA 12100 Printer Queue(队列,优先队列)
- UVa12100 Printer Queue (打印队列)
- UVA12100:Printer Queue(打印队列)
- uva 12100 Printer Queue 习题5-7 打印队列 (STL deque练习)
- UVa 12100 Printer Queue
- UVA - 12100 Printer Queue
- UVa 12100 - Printer Queue
- UVa 12100 - Printer Queue
- UVa: 12100 - Printer Queue
- UVa 12100 - Printer Queue
- uva 12100 Printer Queue
- Uva - 12100 - Printer Queue
- 浅记
- win7/64位下python2.7、easy_install、numpy安装经验
- 高薪技术排行:大数据居首,苹果相…
- 在Lotus Notes 8.5中设…
- 简单安全快速地安装与卸载 Wi…
- 关于“打印队列 Printer Queue, ACM/ICPC NWERC 2006, UVa 12100)"的讨论
- 学习从现在开始!免费计算机技术教…
- 重新认识NTFS文件系统
- Lotus notes直接打开附件,保…
- Notes ID忘记密码处理
- AU3在win7下的指定目录通用命令
- 许多年前,许多年后
- 排序算法五:交换排序之快速排序
- DataSnap数据库连接池,数据集对象池的应用