ZOJ 3230 Solving the Problems
来源:互联网 发布:淘宝的我是卖家在哪里 编辑:程序博客网 时间:2024/05/18 00:24
贪心思想,优先队列处理,用set应该也可以。
#include "cstring"#include "iostream"#include "algorithm"#include "cstdio"#include "queue"#include "set"using namespace std;typedef long long LL;const int M=100050;const int maxn=2147483648;const int INF = 0x3f3f3f3f;int n,m,p;//set<int>q;struct node{ int a,b; bool operator <(const node &c)const { return b<c.b; }} s[M];priority_queue<node> q;bool cmp(node x,node y){ if(x.a==y.a) return y.b>x.b; else return y.a>x.a;}int main(){ while(cin>>n>>m>>p) { for(int i=0; i<n; ++i) cin>>s[i].a>>s[i].b; sort(s,s+n,cmp); int ans=0; while(!q.empty()) q.pop(); for(int i=0; i<m; i++) { while(s[ans].a<=p&&ans<n) { q.push(s[ans]); ans++; } if(!q.empty()) { p+=q.top().b; q.pop(); } } cout<<p<<endl; } return 0;}
0 0
- ZOJ 3230 Solving the Problems
- ZOJ 3230 Solving the Problems
- zoj 3230Solving the Problems//优先队列
- ZOJ 3230 Solving the Problems(优先队列)
- zoj 3230 Solving the Problems (优先队列)
- ZOJ 3230 Solving the Problems(数学 优先队列啊)
- Solving the Problems
- Solving the Problems Zju3230 解题报告
- Mastering the Information Age - Solving Problems with Visual Analytics
- Solving problems with proc
- The Problems of zoj By watashi
- window caffe compiler problems solving
- Tips for solving CSS problems in IE7
- Haskell : Functionally Solving Problems 部分学习笔记
- Problems Solving--Q&&A(Period One)
- Problems Solving--Q&&A(Period 2)
- ZOJ Problems 分类表
- Real-Life MDA: Solving Business Problems with Model Driven Architecture
- 最近有点迷茫,该清醒了
- 2015年06月30日第一天笔记
- Python里面如何生成随机数?
- 总结
- 观察者模式
- ZOJ 3230 Solving the Problems
- pwm的工作原理
- R语言利用RCurl下载验证码图片
- 1062 : 最近公共祖先·一
- flume上传文件到hdfs上
- HDU 3068 最长回文(manacher算法)
- 如何在Docker容器内外互相拷贝数据?
- POJ 1149 PIGS
- Linux Mint (应用软件— 下载工具:Transmission)