#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
typedef long long ll;
typedef pair<int,int> ii;
const int mxN = 1e5+5;
const int mxK = 1e5+5;
int N, K;
ii events[mxN];
int dp[mxN];
int main() {
ios::sync_with_stdio(0); cin.tie(0);
cin >> N >> K;
FOR(i,1,N){
int L, R; cin >> L >> R;
events[i] = ii(L,R);
}
dp[N+1] = 0;
dp[N] = 1;
RFOR(i,N-1,1){
auto it = lower_bound(events+1,events+1+N,ii(events[i].second,0))-events;
dp[i] = dp[it]+1;
}
vector<int> ans;
FOR(i,1,N){
if (ans.empty() || events[ans.back()].second <= events[i].first) {
if (SZ(ans) + dp[i] >= K) {
ans.push_back(i);
}
}
if (SZ(ans) == K) break;
}
if (SZ(ans) < K) {
cout << -1 << '\n';
} else {
for (int& x : ans) {
cout << x << '\n';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Incorrect |
30 ms |
1484 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Incorrect |
30 ms |
1484 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |