C. BQG's Approaching Deadline
Time Limit: 2000ms
Memory Limit: 32768KB
64-bit integer IO format:
%lld Java class name:
Main
很快就到考试周了!但是可怜的
平时过于认真训练,结果欠下了一大堆的作业,平时分岌岌可危!

现在
从
时刻开始做作业,一共有
项作业,第
项作业会在
时刻布置下来(即当
时
可以做这一项作业),需要
的时间完成(假设当
时刻
选择做这一项作业,那么当
时
不能选择做其他作业)。













Input
第一行是一个正整数
,表示测试数据的组数,

对于每组测试数据,
第一行是一个正整数
,表示作业的数量,

接下来
行,

每行包含两个整数
,表示作业布置的时刻和完成作业所需时间。

Output
对于每组测试数据,输出一个整数,表示最早完成所有作业的时刻。
Sample Input
2 3 0 1 1 2 2 3 2 0 1 2 3
Sample Output
6 5
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
struct shu{
int start;
int hour;
}h[10001];
bool compare(struct shu a, struct shu b){
return a.start<b.start;
}
int main(){
int T;
int n;
cin>>T;
while(T--){
cin>>n;
int end=0;
for(int i=0;i<n;i++){
scanf("%d %d",&h[i].start,&h[i].hour);
}
sort(h,h+n,compare);
for(int i=0;i<n;i++){
end=max(end,h[i].start);
end=end+h[i].hour;
}
cout<<end<<endl;
}
return 0;
}