BNU OJ 50999 BQG's Approaching Deadline

#include<cstdio>
#include<algorithm>
using namespace std;

const int maxn=1000+10;
struct Homework
{
    long long st;
    long long len;
}h[maxn];
int n;

bool cmp(const Homework&a,const Homework&b)
{
    return a.st<b.st;
}

int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d",&n);
        for(int i=1;i<=n;i++)
            scanf("%lld%lld",&h[i].st,&h[i].len);
        long long ans=0;
        sort(h+1,h+1+n,cmp);
        for(int i=1;i<=n;i++)
        {
            ans=max(ans,h[i].st);
            ans=ans+h[i].len;
        }
        printf("%lld\n",ans);

    }
    return 0;
}

 

posted @ 2015-12-26 11:28  Fighting_Heart  阅读(186)  评论(0编辑  收藏  举报