Submission #405989

#TimeUsernameProblemLanguageResultExecution timeMemory
405989HalogenThe short shank; Redemption (BOI21_prison)C++14
0 / 100
108 ms4180 KiB
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> ii; 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, vector<int>, greater<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) continue; else if (l != -1) { pq.push(T - A[l - 1]); } l = -1; r = i; ans++; if (i == N) ans--; } } // printf("%d ", ans); while (pq.size() > D) { ans += pq.top(); pq.pop(); } printf("%lld", ans); }

Compilation message (stderr)

prison.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main() {
      | ^~~~
prison.cpp: In function 'int main()':
prison.cpp:40:22: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   40 |     while (pq.size() > D) {
      |            ~~~~~~~~~~^~~
prison.cpp:21:30: warning: variable 'r' set but not used [-Wunused-but-set-variable]
   21 |     int l = -1 + (A[0] > T), r = 0;
      |                              ^
prison.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%lld %lld %lld", &N, &D, &T);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prison.cpp:15:38: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     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...