#include<stdio.h> void main(){ int t; scanf("%d",&t); for(int i=0;i<t;i++){ int n,a[100],b[100]; scanf("%d",&n); for(int j=0;j<n;j++) scanf("%d%d",&a[j],&b[j]); int step=b[0]; while(step<=a[1]){ int flag=1,s=step; for(int j=1;j<n-1;j++){ s+=step; if(s<b[j] || s>a[j+1]){ flag=0;break; } } if(s+step<b[n-1]) flag=0; if(flag){ printf("YES\n"); break; } step++; } if(step>a[1]) printf("NO\n"); } } |
Double click to view unformatted code.