AOAPC:Chapter1Example2 (UVa 11729)
2016-04-14 15:06
309 查看
#include "bits/stdc++.h" using namespace std; int n, b, j, kase = 1; int main(int argc, char const *argv[]) { while (scanf("%d", &n), n) { vector< pair<int, int> > v; for (size_t i = 0; i < n; ++i) { scanf("%d%d", &b, &j); v.push_back(make_pair(j, b)); } sort(v.begin(), v.end()); reverse(v.begin(), v.end()); int res = 0, s = 0; for (size_t i = 0; i < n; ++i) { s += v[i].second; res = max(res, s + v[i].first); } printf("Case %d: %d\n", kase++, res); } return 0; }
相关文章推荐
- maven两个错误的解决方式
- 处理中文乱码
- Android开发中,那些让你相见恨晚的方法、类或接口
- 最大流和最小割
- cef库动态编译
- 什么是OOM?如何解决OOM问题!
- iOS开发-清理缓存功能的实现
- C++ Q&A(六)构造函数的常见问题
- Handler.sendMessage 与 Handler.obtainMessage.sendToTarget比较
- 蓝牙
- SD卡环境变量类的/android存储设备的相关操作
- System Performance Tunning Tools
- 如何才能取到没有在.h文件中声明,但在.m文件中实现的方法
- Linux 加,减,乘,除
- LeetCode——001
- ContentResolver读取音乐文件
- 多态、。。。七大设计原则。。。。
- PHP 函数之 call_user_func & call_user_func_array
- linux rsync
- JVM虚拟机内存模型