UVA 12100
来源:互联网 发布:车用单片机类型 编辑:程序博客网 时间:2024/06/01 08:42
#include<iostream>#include<vector>#include<string>#include<queue>#include<set>#include<algorithm> using namespace std;typedef struct Job{int pr;bool flag;}Job;int main(){int T;cin >> T;while (T--){queue<Job> q;priority_queue<int> pq;int n, m;cin >> n >> m;for(int i=0;i<n;i++){int p;cin >> p;Job j = { p,i==m? true :false };q.push(j);pq.push(p);}int time = 0;while (true){Job J = q.front();q.pop();if (J.pr != pq.top()){q.push(J); }else{time++;pq.pop();if (J.flag)break;}}cout << time << endl;}return 0;}
队首的位置是0比较麻烦,所以用了结构体,在里面加了个flag用来标记我们关注的是哪一个任务。然后跟着题意模拟就行了
优先队列是方便判断优先级的。
阅读全文
0 0
- uva 12100
- uva 12100
- UVA 12100
- UVa 12100
- UVA 12100
- UVA 12100
- Uva 12100
- 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
- UVa 12100 打印队列
- UVA 12100 Printer Queue
- UVa 12100 - Printer Queue
- Python中定义字符串
- 重构第3章读后总结
- 51nod1072---威佐夫博弈(51nod基础:博弈)
- jquery media iframe 内动态显示pdf(兼容ie各个版本 ,火狐,谷歌)
- LS5-linux编程规范之学习笔记
- UVA 12100
- JAVA企业面试题精选 数据库1-10
- Python中raw字符串与多行字符串
- 二十三天
- navicat连接oracle数据库ORA-28547:connection to server failed, probable Oracle Net admin error错误,解决方法
- MATLAB自学第一篇-MATLAB界面介绍和几个常见常量说明
- VCC、VDD、VEE、VSS的区别
- 串口通信数据发送--字符发送和16进制发送--发送字节的间隔时间
- Python中Unicode字符串