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;
int N, D, T;
int R[2000069], U[2000069];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> N >> D >> T;
for (int i = 0; i < N; i++) {
int t;
cin >> t;
int right = i + (T - t);
R[i] = right;
U[i] = t;
}
for (int i = 1; i < N; i++) {
R[i] = max(R[i], R[i - 1]);
}
vector<int> subs;
int last = N;
for (int i = N - 1; i >= 0; i--) {
if (U[i] < T) {
subs.push_back(min(R[i] + 1, last) - i - 1);
last = i;
}
}
sort(subs.begin(), subs.end(), greater<>());
int sum = 0;
for (int i = 0; i < min<int>(D, subs.size()); i++) {
sum += subs[i];
}
cout << N - sum << endl;
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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |