# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1039279 | happy_node | The short shank; Redemption (BOI21_prison) | C++17 | 39 ms | 8384 KiB |
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;
typedef long long ll;
const int MX=2e6+5;
int N,D,T;
int A[MX];
int main() {
cin.tie(0); ios_base::sync_with_stdio(0);
cin>>N>>D>>T;
for(int i=1;i<=N;i++) cin>>A[i];
vector<int> stk;
priority_queue<int> pq;
for(int i=N;i>=1;i--) {
if(A[i]<=T) {
int cur=A[i], cnt=0;
while(stk.size() && stk.back()-i+A[i]<=T) {
cnt++;
stk.pop_back();
}
pq.push(cnt);
} else {
stk.push_back(i);
}
}
int ans=N;
while(pq.size() && D>0) {
D--;
ans-=pq.top();
pq.pop();
}
cout<<ans<<'\n';
}
Compilation message (stderr)
# | 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... |