Submission #587143

#TimeUsernameProblemLanguageResultExecution timeMemory
587143JomnoiHoliday (IOI14_holiday)C++17
47 / 100
140 ms1712 KiB
#include <bits/stdc++.h> #include"holiday.h" using namespace std; const int MAX_N = 1e5 + 5; int N; int A[MAX_N]; long long int findMaxAttraction(int n, int start, int d, int attraction[]) { N = n; for(int i = 0; i < N; i++) { A[i] = attraction[i]; } long long ans = 0; if(N <= 3000) { for(int l = 0; l <= start; l++) { long long sum = 0; priority_queue <int, vector <int>, greater <int>> pq; for(int i = l; i < start; i++) { sum += A[i]; pq.push(A[i]); } for(int r = start; r < N; r++) { sum += A[r]; pq.push(A[r]); while(pq.size() > max(0, d - (r - l) - min(start - l, r - start))) { sum -= pq.top(); pq.pop(); } ans = max(ans, sum); } } } else if(start == 0) { long long sum = 0; priority_queue <int, vector <int>, greater <int>> pq; for(int i = 0; i < N; i++) { sum += A[i]; pq.push(A[i]); while(pq.size() > max(0, d - i)) { sum -= pq.top(); pq.pop(); } ans = max(ans, sum); } } return ans; }

Compilation message (stderr)

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:28:33: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int, std::vector<int>, std::greater<int> >::size_type' {aka 'long unsigned int'} and 'const int' [-Wsign-compare]
   28 |                 while(pq.size() > max(0, d - (r - l) - min(start - l, r - start))) {
      |                       ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
holiday.cpp:43:29: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int, std::vector<int>, std::greater<int> >::size_type' {aka 'long unsigned int'} and 'const int' [-Wsign-compare]
   43 |             while(pq.size() > max(0, 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...