Submission #242454

#TimeUsernameProblemLanguageResultExecution timeMemory
242454joseacazHoliday (IOI14_holiday)C++17
47 / 100
5034 ms2072 KiB
#include"holiday.h" #include <bits/stdc++.h> #define pb push_back #define all(x) x.begin(), x.end() using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpi; typedef vector<pll> vpl; ll findMaxAttraction(int N, int start, int d, int a[]) { int k; ll ans = 0, sum = 0; priority_queue<ll> PQ; //only right if(start == 0) { k = d; for(int j = 0; j < N; j++) { sum += a[j]; PQ.push(-a[j]); while(PQ.size() > k) { sum += PQ.top(); PQ.pop(); } ans = max(ans, sum); //cerr << i << " " << j << " " << sum << "\n"; k--; if(k < 0) break; } return ans; } //first left then right for(int i = start; i >= 0; i--) { k = d - (start - i); sum = 0; while(!PQ.empty()) PQ.pop(); //cerr << k << "\n"; for(int j = i; j < N; j++) { sum += a[j]; PQ.push(-a[j]); while(PQ.size() > k) { sum += PQ.top(); PQ.pop(); } ans = max(ans, sum); //cerr << i << " " << j << " " << sum << "\n"; k--; if(k < 0) break; } } //first right then left for(int i = start; i < N; i++) { k = d - (i - start); sum = 0; while(!PQ.empty()) PQ.pop(); //cerr << k << "\n"; for(int j = i; j >= 0; j--) { sum += a[j]; PQ.push(-a[j]); while(PQ.size() > k) { sum += PQ.top(); PQ.pop(); } //cerr << i << " " << j << " " << sum << "\n"; ans = max(ans, sum); k--; if(k < 0) break; } } return ans; }

Compilation message (stderr)

holiday.cpp: In function 'll findMaxAttraction(int, int, int, int*)':
holiday.cpp:30:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             while(PQ.size() > k)
                   ~~~~~~~~~~^~~
holiday.cpp:56:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             while(PQ.size() > k)
                   ~~~~~~~~~~^~~
holiday.cpp:81:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             while(PQ.size() > k)
                   ~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...