标签:
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1734 Accepted Submission(s): 479
#include<stdio.h> #include<string.h> #include<iostream> #include<algorithm> using namespace std; struct node{ int u,v,m,h; }que[100005]; bool cmp(struct node t1,struct node t2){ if(t1.m==t2.m) return t1.u<t2.u; else return t1.m<t2.m; } int main(){ int n; while(scanf("%d",&n)!=EOF){ if(n==0) break; for(int i=0;i<n;i++){ scanf("%d%d",&que[i].u,&que[i].v); que[i].h=(que[i].v-que[i].u)/2+1; que[i].m=que[i].u+que[i].h; } sort(que,que+n,cmp); int flag=0; for(int i=0;i<n-1;i++){ if(que[i].m>=que[i+1].m){ flag=1; break; } if(que[i].m<que[i+1].u) continue; double temp=que[i].m-que[i+1].u; que[i+1].m=temp+que[i+1].h+que[i+1].u; } if(flag) printf("NO\n"); else printf("YES\n"); } return 0; }
标签:
原文地址:http://www.cnblogs.com/13224ACMer/p/4680960.html