Submission #871886

#TimeUsernameProblemLanguageResultExecution timeMemory
871886tvladm2009Event Hopping 2 (JOI21_event2)C++17
0 / 100
30 ms4688 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...