제출 #894451

#제출 시각아이디문제언어결과실행 시간메모리
894451d4xnThe short shank; Redemption (BOI21_prison)C++17
0 / 100
169 ms180156 KiB
#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 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...