真不知道为啥全是英文题。。。就不能好好的出中文的啊 啊 啊
果然看错了题意
#include <stdio.h>
#include <algorithm>
using namespace std;
struct node
{
long long day,end;
}c[100005];
bool cmp(node x,node y)
{
if(x.end<y.end) return true;
if(x.end==y.end&&x.day>y.day) return true;
return false;
}
int main()
{
int test,n,q=1;
scanf("%d",&test);
while(test--)
{
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%lld %lld",&c[i].day,&c[i].end);
sort(c,c+n,cmp);
long long sum=0,max=0;
for(int i=0;i<n;i++)
{
sum+=c[i].day;
if(sum-c[i].end>max)
max=sum-c[i].end;
}
printf("Case %d: %lld\n",q++,max);
}
return 0;
}
唉 果然理解错了题意 连样例都看不懂