#include<stdio.h> #include<stdlib.h> int main() { int t,n; int left;int right; int len; int pos=0; int flag=1; int time; scanf("%d",&t); if(t>100) return -1; while(t>0) { scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%d %d",&left,&right); if(left>right||right>50000||left<0) return -1; if(i==0) { len=right-left; pos=right; }else{ while(pos<right) { if(pos<left) { time=(left-pos)/len; pos=pos+time*len; } pos+=len; if(pos>left&&pos<right) { flag=0; break; } } } } if(flag) printf("YES\n"); else printf("NO\n"); t--; } return 0; } |
Double click to view unformatted code.