普通 测试帖




嗯嗯

😅
#include<bits/stdc++.h>

using namespace std;

int main(){
    int n,l;
    cin>>n>>l;
    vector<pair<int, int> >all(n);
    for(int i(0);i<n;i++){
        cin>>all[i].first>>all[i].second;
    }
    auto cmp = [](pair<int, int>a,pair<int, int>b) -> bool{return a.first==b.first?a.second>b.second:a.first<b.first;};
    sort(all.begin(),all.end(),cmp);
    bool flag(1);
    int tmp(0),i(0),ans(0);
    for(int i(0);tmp<l&&i<n;){
        ans++;
        int s=tmp;
        for(;all[i].first<=s&&i<n;i++){
            tmp=max(all[i].second,tmp);
        }
        if(tmp==s&&tmp<l)break;
    }
    if(tmp>=l)cout<<ans<<endl;
    else cout<<-1<<endl;
    return 0;
}

#测试##笔试题目#
全部评论
23131
点赞 回复
分享
发布于 2019-07-19 12:05
点赞 回复
分享
发布于 2019-07-24 14:36
春招专场
校招火热招聘中
官网直投
点赞 回复
分享
发布于 2019-08-27 16:38
点赞 回复
分享
发布于 2019-08-31 12:30
啦啦啦 垃圾帖
点赞 回复
分享
发布于 2019-07-08 11:11
发票 12317384792742 发票 12317384792742 发票 12317384792742 发票 12317384792742
点赞 回复
分享
发布于 2019-07-08 11:12
11
点赞 回复
分享
发布于 2019-07-24 14:21
https://www.nowcoder.com/discuss/179790
点赞 回复
分享
发布于 2019-09-03 15:16
啦啦啦
点赞 回复
分享
发布于 2019-09-06 17:24
啦啦啦
点赞 回复
分享
发布于 2019-09-06 17:24

相关推荐

投递腾讯云智研发等公司10个岗位
点赞 评论 收藏
转发
1 收藏 评论
分享
牛客网
牛客企业服务