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 trap[1001][2];
        int mini = 1e9;
        for(int i=0; i<n; i++){
            cin>>trap[i][0]>>trap[i][1];
            if(i<n-1&&trap[i][1]-trap[i][0]<mini)
            {
                mini = trap[i][1]-trap[i][0];
            }
        }
        int f= 1;
        for(int i=0; i<n; i++){
            if(trap[i][0]+mini < trap[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