#include <cstdio>
#include <algorithm>
using namespace std;
typedef struct pp{
int bi, ji;
}pp;
bool cmp(pp a, pp b)
{
return a.ji > b.ji;
}
int main()
{
int n, i, c=0;
pp p[1500];
while(scanf("%d", &n) != -1 && n)
{
for(i=0; i<n; i++)
scanf("%d%d", &p[i].bi, &p[i].ji);
sort(p, p+n, cmp);
int tell = 0;
int val=0; //当前完成任务的最晚时间
for(i=0; i<n; i++)
{
tell += p[i].bi;
val = max(val, tell+p[i].ji);
}
printf("Case %d: %d\n", ++c, val);
}
return 0;
}
UVA 11729 Commando War
最新推荐文章于 2023-12-02 13:59:34 发布