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 i64 = long long;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, k;
std::cin >> n >> k;
std::vector<int> l(n), r(n);
for (int i = 0; i < n; i++) {
std::cin >> l[i] >> r[i];
}
std::vector<int> dp(n, 0), suff(n + 1, 0);
for (int i = n - 1; i >= 0; i--) {
int pos = std::lower_bound(l.begin(), l.end(), r[i]) - l.begin();
dp[i] = suff[pos] + 1;
suff[i] = std::max(suff[i + 1], dp[i]);
}
int last = 0;
for (int i = 0; i < n; i++) {
if (l[i] >= last && dp[i] >= k) {
last = r[i];
k--;
std::cout << i + 1 << "\n";
}
if (k == 0) {
break;
}
}
return 0;
}
# | 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... |