Submission #405956

#TimeUsernameProblemLanguageResultExecution timeMemory
405956HalogenThe short shank; Redemption (BOI21_prison)C++14
0 / 100
76 ms5352 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int N, D, T; int A[2000005]; main() { scanf("%lld %lld %lld", &N, &D, &T); for (int i = 0; i < N; i++) scanf("%lld", &A[i]); priority_queue<int> pq; int ans = 0; int l = -1 + (A[0] > T), r = 0; for (int i = 0; i <= N; i++) { if (A[i] > T) { if (l == -1) l = i; r = i; } else { if (l == 0) { ans += r - l + 1; } else if (l != -1) { pq.push(r - l + 1); // printf("%lld\n", r - l + 1); } l = -1; r = i; } } for (int i = 0; i < D; i++) { ans += pq.top(); pq.pop(); } printf("%lld", N - ans); }

Compilation message (stderr)

prison.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main() {
      | ^~~~
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("%lld %lld %lld", &N, &D, &T);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prison.cpp:13:38: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     for (int i = 0; i < N; i++) scanf("%lld", &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...