Submission #1064227

#TimeUsernameProblemLanguageResultExecution timeMemory
1064227VMaksimoski008Holiday (IOI14_holiday)C++17
47 / 100
5064 ms1964 KiB
#include "holiday.h" #include <bits/stdc++.h> using namespace std; using ll = long long; ll findMaxAttraction(int n, int start, int d, int attraction[]) { if(start == 0) { ll ans = 0, sum = 0; priority_queue<ll, vector<ll>, greater<ll> > pq; for(int i=0; i<min(d, n); i++) { pq.push(attraction[i]); sum += attraction[i]; while(pq.size() > d - i) { sum -= pq.top(); pq.pop(); } ans = max(ans, sum); } return ans; } if(start != 0) { ll ans = 0, sum = 0; priority_queue<ll, vector<ll>, greater<ll> > pq; //edna nasoka samo for(int i=start; i>=0; i--) { if(start - i >= d) break; pq.push(attraction[i]); sum += attraction[i]; while(pq.size() > d - (start - i)) { sum -= pq.top(); pq.pop(); } ans = max(ans, sum); } sum = 0; while(!pq.empty()) pq.pop(); for(int i=start; i<n; i++) { if(i - start >= d) break; pq.push(attraction[i]); sum += attraction[i]; while(pq.size() > d - (i - start)) { sum -= pq.top(); pq.pop(); } ans = max(ans, sum); } for(int i=start-1; i>=0; i--) { sum = 0; while(!pq.empty()) pq.pop(); for(int j=i; j<=start; j++) { sum += attraction[j]; pq.push(attraction[j]); } for(int j=start+1; j<n; j++) { if(2 * min(j - start, start - i) + max(j - start, start - i) >= d) break; sum += attraction[j]; pq.push(attraction[j]); while(pq.size() > d - 2 * min(j - start, start - i) - max(j - start, start - i)) { sum -= pq.top(); pq.pop(); } ans = max(ans, sum); } } return ans; } return 0; }

Compilation message (stderr)

holiday.cpp: In function 'll findMaxAttraction(int, int, int, int*)':
holiday.cpp:14:29: 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 'int' [-Wsign-compare]
   14 |             while(pq.size() > d - i) {
      |                   ~~~~~~~~~~^~~~~~~
holiday.cpp:35:29: 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 'int' [-Wsign-compare]
   35 |             while(pq.size() > d - (start - i)) {
      |                   ~~~~~~~~~~^~~~~~~~~~~~~~~~~
holiday.cpp:51:29: 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 'int' [-Wsign-compare]
   51 |             while(pq.size() > d - (i - start)) {
      |                   ~~~~~~~~~~^~~~~~~~~~~~~~~~~
holiday.cpp:73:33: 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 'int' [-Wsign-compare]
   73 |                 while(pq.size() > d - 2 * min(j - start, start - i) - max(j - start, start - 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...