竞赛讨论区 > E题为什么这样也能过?
头像
Jor蛋
发布于 2022-05-22 13:53
+ 关注

E题为什么这样也能过?

#include<bits/stdc++.h>
#define int long long 
using namespace std;
const int N=1e5+10;
int w[N];
signed main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>w[i];
    }
    sort(w,w+n);
    int last1,last2;
    cin>>last1>>last2;
    bool st=true;
    for(int i=2;i<=n;i++){
        int a,b;cin>>a>>b;
        int maxn=b-last1,minn=a-last2;
        int p=lower_bound(w,w+m,minn)-w;
        if(w[p]>=minn&&w[p]<=maxn){
            last1=a,last2=b;
        }else st=false;
    }
    if(st) cout<<"YES";
    else cout<<"NO";
}

全部评论

(0) 回帖
加载中...
话题 回帖

等你来战

查看全部

热门推荐