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 rep(i,s,e) for (int i = s; i <= e; ++i)
#define rrep(i,s,e) for (int i = s; i >= e; --i)
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, D, T; cin >> n >> D >> T;
int t[n+2];
rep (i,1,n) cin >> t[i];
int cnt[n+1] = {}, cnt2[n+1] = {}, ans = 0;
set<ii> st;
set<int> st2;
rep (i,1,n) {
if (t[i]>T) {
while (!st.empty() && (*st.begin()).fi < i) {
int j = (*st.begin()).se;
st.erase(st.begin());
st2.erase(j);
}
if (st.empty()) ++ans;
else {
cnt[*st2.rbegin()]++;
cnt2[i]++;
}
}
else {
st.insert({i+T-t[i],i});
st2.insert(i);
}
}
int cur = 0, ans2 = 0;
rep (i,1,n) {
cur += cnt[i] - cnt2[i];
ans2 = max (ans2, cur);
}
cout << n-ans-ans2 << "\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... |