# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
405984 | Halogen | The short shank; Redemption (BOI21_prison) | C++14 | 75 ms | 6312 KiB |
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
typedef pair<int, int> ii;
int N, D, T;
int A[2000005];
main() {
scanf("%lld %lld %lld", &N, &D, &T);
for (int i = 0; i < N; i++) scanf("%lld", &A[i]);
vector<ii> pq;
int ans = 0;
int l = -1 + (A[0] > T), r = 0;
for (int i = 0; i <= N; i++) {
if (A[i] > T) {
if (l == -1) l = i;
r = i;
}
else {
if (l == 0) {
ans += r - l + 1;
}
else if (l != -1) {
pq.push_back({ r - l + 1, max(0ll, r - l + 1 - T + A[l - 1]) });
}
l = -1;
r = i;
}
}
sort(pq.begin(), pq.end(), [](ii o1, ii o2) {
return o1.second - o1.first < o2.second - o2.first;
});
for (ii i : pq) {
// printf("%lld %lld\n", i.first, i.second);
if (D--) ans += i.first;
else ans += i.second;
}
printf("%lld", N - ans);
}
Compilation message (stderr)
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |