天天看點

Level Statistics

​​A. Level Statistics​​

思考的時候一定不要擔心會浪費時間!!

要把問題考慮清楚!!

// Created by CAD on 2020/4/10.
#include <bits/stdc++.h>
using namespace std;

int p[105],c[105];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;cin>>t;
    while(t--){
        int n;cin>>n;
        int maxp=0,maxc=0;
        for(int i=1;i<=n;++i) cin>>p[i]>>c[i];
        bool ans=1;
        for(int i=1;i<=n;++i){
            if(p[i]<maxp||c[i]<maxc) ans=0;       //保證單調遞增
            if(c[i]-c[i-1]>p[i]-p[i-1]) ans=0;   //保證c增加的比p少
            maxp=max(p[i],maxp),maxc=max(c[i],maxc);
        }
        if(ans) cout<<"YES\n";
        else cout<<"NO\n";
    }
    return 0;
}