#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct job{
int j,b;
bool operator<(const job&x)const{
return j>x.j;
}
};
int main(){
int n,b,j,s=0,ans=0,casenum=1;
vector<job> v;
while(scanf("%d",&n)==1&&n){
for(int i=0;i<n;i++){
scanf("%d%d",&b,&j);
v.push_back((job){j,b});
}
sort(v.begin(),v.end());
for(int i=0;i<n;i++){
s+=v[i].b;
ans=max(ans,s+v[i].j);
}
printf("Case %d: %d",casenum++,ans);
}
return 0;
}
uva 11729
最新推荐文章于 2023-12-02 13:59:34 发布