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 a[1000],b[1000],max=0;
    	for(int i = 0; i < n; i++){
    		cin>>a[i]>>b[i];
    		if(b[i]-a[i]>max){
    			max = b[i]-a[i];
			}
		}
		int flag = 1;
		for(int i = 0; i < n-1; i++){
    		if(a[i+1] - a[i] < max){
    			flag = 0;
    			break;
			 }
		}
		if(flag==0) cout<<"NO"<<endl;
		else cout<<"YES"<<endl;
	}
}

Double click to view unformatted code.


Back to problem 6