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 finish(x) return cout << x << endl, 0
#define ll long long
int n, d, t;
vector <int> a;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> d >> t;
a.resize(n);
for(auto &i : a) cin >> i;
vector <int> g(n);
for(int i = n - 2 ; i >= 0 ; i--){
if(a[i + 1] <= t) g[i] = 0;
else g[i] = g[i + 1] + 1;
}
vector <int> all;
for(int i = 0 ; i + 1 < n ; i++){
if(a[i] <= t && a[i + 1] <= t){
a[i + 1] = min(a[i + 1], a[i] + 1);
}
}
for(int i = 0 ; i + 1 < n ; i++){
if(a[i] <= t && a[i + 1] > t){
all.push_back(min(g[i], t - a[i]));
}
}
sort(all.begin(), all.end());
int ans = 0;
for(int i = 0 ; i < n ; i++){
ans += a[i] <= t;
}
while(all.size() && d > 0){
all.pop_back();
d--;
}
for(auto &i : all) ans += i;
cout << ans << "\n";
}
# | 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... |