View Code of Problem 6

#include <stdio.h>
#include <string.h>
#include <math.h>
struct xj{
	int start;
	int end;
};


int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int n;
		int flag=1;
		int dismax=0;
		scanf("%d",&n);
		struct xj list[n];
		for(int i=0;i<n;i++){
			scanf("%d %d",&list[i].start,&list[i].end);
			if(dismax<list[i].end-list[i].start){
				dismax=list[i].end-list[i].start;
			}
		}
		for(int i=0;i<n-1;i++){
			if(dismax>(list[i+1].start-list[i].start)){
				flag=0;
			}
		
		}
		if(flag)
			printf("YES\n");
		else
			printf("NO\n");
		
	}

}

Double click to view unformatted code.


Back to problem 6