이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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[(*st.begin()).se]++;
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... |