蓝书 LA 3135 优先队列入门
2017-01-17 22:04
316 查看
传送门:LA 3135
题解
优先对列入门运用优先对列支持<重载, 可保持队列的有序性
AC code:
/* File : 优先队列.cpp Author : adrui Lang : C++ */ #include<iostream> #include<queue> #include<cstdio> using namespace std; struct Node{ int t, num, p; bool operator < (const Node& R) const{ if(t == R.t) return num > R.num; return t > R.t; } }; int main(){ //freopen("in.txt", "r", stdin); char s[30]; Node r; int k; priority_queue<Node> q; while(cin >> s, s[0] != '#'){ cin >> r.num >> r.p; r.t = r.p; q.push(r); } cin >> k; while(k--){ Node tmp = q.top(); q.pop(); cout << tmp.num << endl; tmp.t += tmp.p; q.push(tmp); } return 0; }
相关文章推荐
- LA_3135优先队列
- (算法入门经典大赛 优先级队列)LA 3135(之前K说明)
- LA_3135优先队列
- LA_3135优先队列
- LA 3135 Argus ( 优先队列 )
- 优先队列 阿格斯(Argus Beijing La 3135)
- UVALive - 3135 Argus【优先队列】
- (算法竞赛入门经典 优先队列)LA 3135(前K条指令)
- UVALive - 3135 - Argus (优先队列!!)
- UVALive 3135--Argus+自定义优先队列的优先规则
- 【优先队列之多路归并】UVALive 3135 Argus
- POJ ROADS DFS BFS 优先队列 入门
- LA 4254 Processor 处理器 【二分 贪心 优先队列】
- 指南 第三章 例题3 UVALive 3135 Argus(优先队列的应用)
- UVALive 3135--Argus+自己定义优先队列的优先规则
- uva11997 K Smallest Sums&&UVALive 3135 Argus(优先队列,多路归并)
- 算法入门--最大堆实现优先队列
- 数据结构入门--优先队列简单排序
- LA - 4254,二分,优先队列,贪心
- 优先队列入门