/*
Commando War, UVa 11729 贪心题目
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
const int maxn=1005;
int n;
struct node
{
int b;
int j;
} p[maxn];
int cmp(node a,node b)
{
return a.j>b.j;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif // ONLINE_JUDGE
int tcase=0;
while(scanf("%d",&n),n)
{
for(int i=0; i<n; i++)
{
scanf("%d%d",&p[i].b,&p[i].j);
}
sort(p,p+n,cmp);
int ans=0;
int sum=0;
for(int i=0; i<n; i++)
{
sum+=p[i].b;
ans=max(ans,sum+p[i].j);
}
printf("Case %d: %d\n",++tcase,ans);
}
return 0;
}
Commando War, UVa 11729
最新推荐文章于 2019-04-03 20:58:15 发布