标签:
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int inf = 0x3f3f3f3f; struct edge{ int r,e,l; }t[100010]; bool cmp(edge i,edge j) { return i.e < j.e; } int main() { int T,n,r,e,l; bool flag; scanf("%d",&T); for(int cas = 1; cas <= T;cas++){ scanf("%d",&n); for(int i = 1; i <= n ;i++){ scanf("%d%d%d",&t[i].r,&t[i].e,&t[i].l); } sort(t+1,t+n+1,cmp); int max1 = 0,max2 = inf; int m = 0; flag = false ; for(int i = 1; i <= n; i++){ if(i == 1) m = t[i].r; else m = max2 + t[i].r; if(m > t[i].e){ flag = true; break; } max1 += t[i].r; max2 = min(max1+t[i].l,max2); } printf("Case #%d: ",cas); if(flag == false) printf("YES\n"); else printf("NO\n"); } return 0; }
标签:
原文地址:http://www.cnblogs.com/zero-begin/p/4532182.html