View Code of Problem 6

#include<stdlib.h>
#include<stdio.h>


int distance[100000][2];
int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		int n;
		scanf("%d",&n);
		int max=0;
		for(int i=0; i<n; i++){
			scanf("%d %d",&distance[i][0],&distance[i][1]);
			if((distance[i][1] - distance[i][0]) > max)
				max = distance[i][1] - distance[i][0];
		}
		int flag = 0;
		for(int i=0; i<n-1; i++){
			if(max + distance[i][0] > distance[i+1][0]){
				flag = 1;
				break;
			}
				
		}	
		if(flag==0)
			printf("YES\n");
		else
			printf("NO\n");
	}


	return 0;
}

Double click to view unformatted code.


Back to problem 6