Submission #675500

#TimeUsernameProblemLanguageResultExecution timeMemory
675500bashkortHoliday (IOI14_holiday)C++17
47 / 100
5085 ms2364 KiB
#include "holiday.h" #include <bits/stdc++.h> using namespace std; using ll = long long; ll solve(int n, int start, int d, int attraction[]) { priority_queue<int, vector<int>, greater<>> pq; ll ans = 0, sum = 0; for (int i = start; i < n; ++i) { pq.push(attraction[i]); sum += attraction[i]; while (!pq.empty() && pq.size() + (i - start) > d) { sum -= pq.top(); pq.pop(); } ans = max(ans, sum); } return ans; } ll findMaxAttraction(int n, int start, int d, int attraction[]) { ll ans = 0; if (start == 0) { return solve(n, start, d, attraction); } else { for (int _ = 0; _ < 2; ++_) { for (int i = 0; i <= start; ++i) { if (start - i < d) { ans = max(ans, solve(n, i, d - (start - i), attraction)); } } reverse(attraction, attraction + n); start = n - start - 1; } } return ans; }

Compilation message (stderr)

holiday.cpp: In function 'll solve(int, int, int, int*)':
holiday.cpp:13:55: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int, std::vector<int>, std::greater<void> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |         while (!pq.empty() && pq.size() + (i - start) > d) {
      |                               ~~~~~~~~~~~~~~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...