hdu 4393 优先队列
2017-02-11 12:21
274 查看
// // main.cpp // STL-优先队列 // // Created by liuzhe on 16/12/21. // Copyright © 2016年 my_code. All rights reserved. // #include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<queue> using namespace std; struct node { int f,id; bool operator <(const node &b)const { return (f<b.f||(f==b.f&&id>b.id)); } }; priority_queue<node> s[105]; int main(int argc, const char * argv[]) { // insert code here... int t; cin>>t; int cas=1; while(t--) { int n; scanf("%d",&n); for(int i=1;i<=n;i++) { node t; int f,d; scanf("%d%d",&f,&d); t.f = f; t.id = i; s[d].push(t); } printf("Case #%d:\n",cas++); for(int i=1;i<=n;i++) { int maxx = -1; int minid = 100000000; int ans; for(int j=1;j<=100;j++) if(!s[j].empty()) { node t = s[j].top(); if((i-1)*j+t.f>maxx||((i-1)*j+t.f==maxx&&t.id<minid)) { maxx = (i-1)*j+t.f; ans = j; minid = t.id; } } int tmp = s[ans].top().id; if(i!=n) printf("%d ",tmp); else printf("%d\n",tmp); s[ans].pop(); } } //std::cout << "Hello, World!\n"; return 0; }
相关文章推荐
- hdu 4393(优先队列)
- hdu 4393 Throw nails(优先队列)
- HDU 4666 Hyperspace(优先队列)
- hdu 2822 Dogs 优先队列
- HDU 1026 Ignatius and the Princess I(优先队列+打印路径)
- hdu 4544 优先队列+贪心
- hdu 5360 Hiking (优先队列+贪心)
- HDU 1103 Flo's Restaurant(模拟+优先队列)
- HDU 1242 Rescue (广搜 + 优先队列)
- hdu 6071 Lazy Running(优先队列+dijkstra)(2017 Multi-University Training Contest - Team 4)
- HDU 1896 Stones 优先队列
- HDU 1873 看病要排队(优先队列)
- 【HDU】1285--确定比赛名次(拓扑&&优先队列)
- priority_queue && Dijkstra 对优先队列优化的Dijkstra算法的理解 hdu 3790
- hdu 4006 The kth great number(优先队列)
- hdu 4544 湫湫系列故事——消灭兔子 优先队列+贪心
- HDU——1233还是畅通工程(克鲁斯卡尔+优先队列)
- hdu 5818 Joint Stacks (优先队列)
- HDU 5437 Alisha’s Party(2015ACM长春赛区网络赛+优先队列)
- hdu 1873 看病要排队(优先队列)