您的位置:首页 > 其它

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: