View Code of Problem 6

#include<stdio.h>
int main(){
	int n,i,t;
	scanf("%d",&t);
	while(t--){
	scanf("%d",&n);	
	int a[n][2];
	for(i=0;i<n;i++){
		scanf("%d %d",&a[i][0],&a[i][1]);
	}	
	int max=0;
	for(i=0;i<n;i++){
			int b;
			b=a[i][1]-a[i][0];
			if(b>max) max=b;
		}
	for(i=0;i<n-1;i++){
			if(a[i][0]+max>a[i+1][0]){
				printf("NO\n");
				break;
			}
		}
		if(i>=n-1) printf("YES\n");
	}
	return 0;	
}

Double click to view unformatted code.


Back to problem 6