Submission #425750

#TimeUsernameProblemLanguageResultExecution timeMemory
425750zoooma13The short shank; Redemption (BOI21_prison)C++14
0 / 100
92 ms9028 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n ,k ,T; scanf("%d%d%d",&n,&k,&T); vector <int> a(n); for(int&i : a) scanf("%d",&i); int ans = 0; vector <int> pp(n); vector <pair<int ,int>> q; for(int i = 0; i < n; i++){ while(!q.empty() && q.back().first > T-i) q.pop_back(); if(a[i] <= T){ while(!q.empty() && q.back().first >= a[i]-i) q.pop_back(); q.push_back({a[i]-i ,i}); }else if(!q.empty()) pp[q.back().second]++; else ans++; } sort(pp.rbegin() ,pp.rend()); for(int i = 0; i < k; i++) ans += pp[i]; printf("%d\n",n-ans); }

Compilation message (stderr)

prison.cpp: In function 'int main()':
prison.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%d%d%d",&n,&k,&T);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
prison.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         scanf("%d",&i);
      |         ~~~~~^~~~~~~~~
#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...