/*
* 11292.cpp
*
* Created on: Dec 31, 2012
* Author: joker
*/
#define Main 1
#define INPUT_REDIRECT "11729.test"
#if Main
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int maxn = 1000 + 5;
typedef struct _Job {
int b, j;
bool operator <(const _Job & x) const {
return j > x.j;
}
} Job;
int main(int argc, char **argv) {
#ifndef ONLINE_JUDGE
freopen(INPUT_REDIRECT, "r", stdin);
#endif
Job jobs[maxn];
int n, ncase = 1;
while (scanf("%d", &n) == 1 && n) {
int bmax = 0, start = 0;
for (int i = 0, b, j; i < n; ++i) {
scanf("%d%d", &b, &j);
jobs[i].b = b;
jobs[i].j = j;
}
//qsort(jobs, n, sizeof(Job), comparer);
sort(jobs, jobs + n);
bmax = 0;
start = 0;
for (int i = 0, tmp; i < n; ++i) {
start += jobs[i].b;
bmax = max(bmax, start + jobs[i].j);
}
printf("Case %d: %d\n", ncase++, bmax);
}
}
#endif
CPP忘的差不多了,晕。
uva11729
最新推荐文章于 2024-05-01 21:37:48 发布