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;
}
posted @ 2020-04-12 17:20  caoanda  阅读(201)  评论(0编辑  收藏  举报