uva 11729
2015-09-12 15:44
381 查看
<pre name="code" class="cpp">#include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <string> #include <cstring> #include <vector> #include <set> #include <queue> #include <map> using namespace std; const int MAXN = 1000 + 10; const int MAXM = 1000000000 + 1000; typedef long long LL; /* uva 11729 */ int main(){ int N,Case=0; scanf("%d",&N); // N:number of soldiers while( N!=0 ){ ++Case; multimap<int,int> m; int B,J; for(int i=0; i<N; i++){ cin >> B >> J; m.insert(pair<int,int>(J,B)); } multimap<int,int>::reverse_iterator rt = m.rbegin(); int total_need = 0, done_need = 0; while( rt != m.rend() ){ int first = (*rt).first; int second = (*rt).second; total_need += second; done_need = max(first,done_need-second); rt++; } total_need += done_need; cout << "Case " << Case << ": " << total_need << endl; scanf("%d",&N); } return 0; }
相关文章推荐
- 对象的序列化和反序列化
- epoll详解
- 车皮编序问题
- 一个标准的JavaBean组件的特性
- 两分钟彻底让你明白Android Activity生命周期(图文)!
- poll内核源代码剖析
- 反恐训练营(LCS)
- HDU 1106
- Smali语法汇总(一)
- Smali语法汇总(一)
- Effective C++ 条款48 认识template元编程
- linux下如何挂载光驱
- Mina、Netty、Twisted一起学:整合protobuf
- 类型转换函数 & 转换构造函数
- 生产者/消费者模式
- JVM监测工具和实践
- CLI下另一种多进程实现方式----PCNTL
- CMake 学习笔记 —— 初见
- switch
- 关于struts2两个常量i18n.reload和static.browserCache的作用。