Submission #492762

#TimeUsernameProblemLanguageResultExecution timeMemory
492762LukapThe short shank; Redemption (BOI21_prison)C++14
0 / 100
196 ms10928 KiB
#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[prosli]) 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...