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

Double click to view unformatted code.


Back to problem 6