Submission #604781

#TimeUsernameProblemLanguageResultExecution timeMemory
604781hibikiThe short shank; Redemption (BOI21_prison)C++11
0 / 100
68 ms9044 KiB
#include<bits/stdc++.h> using namespace std; int n, d, t; int a[2000005], re[2000005]; int ans = 1e9, lst = -1e9, cnt = 0; priority_queue<int> g; int main() { scanf("%d %d %d", &n, &d, &t); for(int i = 1; i <= n; i++) { scanf("%d", &a[i]); re[i] = re[i - 1]; if(a[i] <= t) re[i]++, lst = i; else if(i - lst <= t) re[i]++; } lst = n + 1; for(int i = n; i > 1; i--) { if(a[i] <= t) { cnt++; cnt += min(t - a[i], lst - i - 1); lst = i; } ans = min(ans, cnt + re[i - 1]); } printf("%d\n",ans); return 0; }

Compilation message (stderr)

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