Commando War

来源:互联网 发布:弱电网络进度计划表 编辑:程序博客网 时间:2024/06/06 12:41
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
#define max 10000
struct A 
{int b;int j;};


bool cmp(struct A i,struct A j)
{
return i.j>j.j;//
}



int main(int argc, char const *argv[])
{
int i;
int n=0;
struct A a[max]; 

while(scanf("%d",&i)==1 &&  i)
{
int ti =0;


for(int j=0;j<i;j++)
scanf("%d%d",&a[j].b,&a[j].j);
sort(a,a+i,cmp);//
int t=0;
for(int j=0;j<i;j++)
{
ti=(a[j].b+a[j].j+t)>ti ? (a[j].b+a[j].j+t): ti;
t+=a[j].b;
}
n++;
cout<<"Case "<<n<<": "<<ti<<endl;


}
return 0;
}



0 0
原创粉丝点击