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 int long long
const int N = 3e6+6;
int n, d, t, a[N], b[N];
vector<int> add[N], rem[N];
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> d >> t;
for (int i = 0; i < n; i++) {
b[i] = 0;
cin >> a[i];
if (a[i] > t) continue;
add[i].push_back(i);
rem[min(n, i + t-a[i] + 1)].push_back(i);
}
set<int> st;
int ans = 0;
for (int i = 0; i < n; i++) {
for (int& j : add[i]) st.insert(j);
for (int& j : rem[i]) st.erase(j);
if (a[i] <= t) continue;
if (st.empty()) ans++;
else b[*prev(st.end())]++;
}
sort(b, b+n);
for (int i = n-1; i >= max(0ll, n-1 - d + 1); i--) {
ans += b[i];
}
cout << n - 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... |