Submission #1039279

#TimeUsernameProblemLanguageResultExecution timeMemory
1039279happy_nodeThe short shank; Redemption (BOI21_prison)C++17
0 / 100
39 ms8384 KiB
#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)

prison.cpp: In function 'int main()':
prison.cpp:22:29: warning: unused variable 'cur' [-Wunused-variable]
   22 |                         int cur=A[i], cnt=0;
      |                             ^~~
#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...