POJ5437-Alisha’s Party
2015-09-16 13:57
323 查看
优先队列,注意对时间排序,不要越界(越界WA了好多次)
#include<iostream> #include<cmath> #include<cstdio> #include<cstring> #include<map> #include<set> #include<string> #include<algorithm> #include<queue> #include<stack> using namespace std; struct node { char name[205]; int v,id; }a[150005];; bool operator<(const node &a,const node &b) { if(a.v==b.v) return a.id>b.id; return a.v<b.v; } struct time { int t; int p; }b[150005]; int cmp(time a,time b) { return a.t<b.t; } int main(){ int cas; scanf("%d",&cas); int k,m,q; while(cas--) { priority_queue<node> xl; scanf("%d%d%d",&k,&m,&q); for(int i=0;i<k;i++){ scanf("%s%d",a[i].name,&a[i].v); a[i].id=i; } for(int i=0;i<m;i++) scanf("%d%d",&b[i].t,&b[i].p); int t=1; sort(b,b+m,cmp); int ans[150005]; int y=0; for(int i=0;i<k;i++){ xl.push(a[i]); if(y<m&&i+1==b[y].t){ for(int j=0;j<b[y].p&&!xl.empty();j++){ ans[t++]=xl.top().id; xl.pop(); } y++; } } while(!xl.empty()){ ans[t++]=xl.top().id; xl.pop(); } for(int i=0;i<q;i++){ int n; scanf("%d",&n); printf(i==q-1?"%s\n":"%s ",a[ans ].name); } } return 0; }
相关文章推荐
- Flow Layout-2014
- WinDbg调试.NET程序入门
- 使用MySQL命令行新建用户并授予权限的方法
- javascript 交互取值
- 51信用卡通过网银来获得账单的安全问题
- 轻松自动化---selenium-webdriver(python) (十二)
- python pip安装 PIL
- SVN使用教程总结
- 删除依赖命令
- block 传值 1
- 轻松自动化---selenium-webdriver(python) (十一)
- OGG实现两台Oracle数据库的同步
- 安装MySQL之后修改编码方式
- 删RAC中间ASM和LISTENER 资源的正确方法
- DFA
- C基础01天——常量变量笔记
- grouping sets,cube,rollup,grouping__id,group by
- flex画图demo
- Swift第三课 分支语句 if else for forin switch while do-while
- 轻松自动化---selenium-webdriver(python) (十)