View Code of Problem 6

#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		int t[n][2];
		int max=0;
		for(int i=0;i<n;i++){
			cin>>t[i][0]>>t[i][1];
			if((t[i][1]-t[i][0])>max){
				max=t[i][1]-t[i][0];
			}
		}
		bool flag=true;
		for(int i=0;i<n-1;i++){
			if(t[i][0]+max>t[i+1][0]){
				flag=false;
				break;
			}
		}
		if(flag)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	
	return 0;
}

Double click to view unformatted code.


Back to problem 6