View Code of Problem 6

#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
	int T,n;
	int l[100],r;
	cin>>T;
	for(int i=0;i<T;i++){
	    int bo=0,s=0;		
		cin>>n;
		for(int j=0;j<n;j++){
			cin>>l[j]>>r;
			s=max(s,r-l[j]);
			
		}
		for(int k=0;k<n;k++){
			if(l[k+1]-l[k]<s) bo=-1;
		}
		
		if(bo==0) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;		
	}
	
}

Double click to view unformatted code.


Back to problem 6