BUN 1020--信息战(六)——军队体检 ——优先队列
2014-07-03 15:57
134 查看
题目链接点击打开链接
使用优先队列
复习优先队列自定义排序函数以及pop push top等操作。
AC代码
使用优先队列
复习优先队列自定义排序函数以及pop push top等操作。
AC代码
#include<iostream> #include<algorithm> #include<iomanip> #include<queue> using namespace std; struct node { friend bool operator <(node x,node y) { return x.value > y.value; } double value; }; bool cmp(node a, node b) { return a.value>b.value; } node a[1000005]; int main() { int t; cin>>t; while(t--) { int n,m,p,i,j,sum=0; cin>>n>>m>>p; for(i=0; i<n; i++) { cin>>a[i].value; } sort(a,a+n,cmp); priority_queue<node> q; for(i = 0; i<m; i++) { q.push(a[i]); } for(i=m; i<n; i++) { node tmp=q.top(); q.pop(); tmp.value+=a[i].value; q.push(tmp); } node tmp; while(!q.empty()) { tmp=q.top(); q.pop(); } cout<<fixed<<setprecision(3)<<tmp.value/p<<endl; } }
相关文章推荐
- BNUOJ 1020 信息战(六)——军队体检 (STL之优先队列)
- BOJ 1020 信息战(六)——军队体检
- 学习笔记:[上课卖萌]优先队列不详解
- CodeForces 128 B.String(优先队列)
- Stones 优先队列
- BZOJ 3689: 异或之 字典树 优先队列
- Fence Repair (优先队列)
- PAT basic 1020
- hdu 6071 Lazy Running(优先队列+dijkstra)(2017 Multi-University Training Contest - Team 4)
- priority_queue优先队列
- UVa-11136 Hoax or what(优先队列或multiset)
- HDU 6136 模拟 + 优先队列
- HDU - 6168 Numbers(贪心+优先队列)
- 51nod 1020 逆序排列——dp
- [PAT-甲级]1020.Tree Traversals
- Codeforces 854 C Planning(优先队列+贪心)
- The kth great number (优先队列)
- ZOJ - 2724 Windows Message Queue——优先队列
- PAT [A1020]-Tree Traversals
- luoguP1020 导弹拦截 题解