#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; }
BNU OJ 50999 BQG's Approaching Deadline
时间: 2024-10-10 07:18:38