This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,k;
cin >> n >> k;
vector<pair<int,int>> ranges(n);
vector<int> maxchoose(n+1);
for(auto&[a,b]:ranges)cin>>a>>b;
int last = 1e10;
for(int i=n-1;i>=0;i--){
if(ranges[i].second<=last){
last = ranges[i].first;
maxchoose[i]=maxchoose[i+1]+1;
} else maxchoose[i]=maxchoose[i+1];
}
if(maxchoose[0]<k){
cout << "-1\n";
return 0;
}
vector<int> ans;
int curr = 0;
for(int i=0;i<n;i++){
if(curr==k)break;
int idx = lower_bound(ranges.begin(),ranges.end(),make_pair(ranges[i].second,0ll))-ranges.begin();
if(curr+1+maxchoose[idx]>=k){ans.emplace_back(i);i=idx-1;curr++;}
}
for(int&i:ans)cout<<++i<<'\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |