#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define ll long long
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll,ll>
#define all(x) (x).begin(),(x).end()
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n,d,t;
cin >> n >> d >> t;
vi a(n);
for (int i=0; i<n; i++) {
cin >> a[i];
}
vi pref(n+2,0);
vector<pi> state;
for (int i=0; i<n; i++) {
if (a[i]>t) {
while (state.size() && state.back().fi<i) {
state.pop_back();
}
if (state.size()) {
pref[state.back().se+2]++;
pref[i+2]--;
}
}
else {
state.pb({i+t-a[i],i});
}
}
for (int i=1; i<n+2; i++) {
pref[i]+=pref[i-1];
}
cout << n-*max_element(all(pref)) << '\n';
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... |