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;
const int MAXN = 2e6 + 7;
int n, d, t;
int vri[MAXN], akt[MAXN], dp[MAXN];
int uk;
int main () {
cin >> n >> d >> t;
for (int i = 0; i < n; i++) cin >> vri[i];
for (int i = 0; i < n; i++) {
if (vri[i] <= t) akt[i] = 1;
}
int prosli = -1;
for (int i = 0; i < n; i++) {
if (akt[i] == 1) prosli = i;
else if (prosli == -1 || i - prosli > t - vri[i]) akt[i] = -1;
else akt[i] = 0;
}
for (int i = 0; i < n; i++) {
if (akt[i] != -1) uk++;
}
dp[n] = 0;
for (int i = n - 1; i >= 0; i--) {
if (akt[i] != 0) continue;
dp[i] = dp[i + 1] + 1;
dp[i + 1] = 0;
}
sort (dp, dp + n);
reverse(dp, dp + n);
for (int i = 0; i < d; i++) uk -= dp[i];
cout << uk;
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... |