Submission #66596

#TimeUsernameProblemLanguageResultExecution timeMemory
66596aquablitz11Holiday (IOI14_holiday)C++14
47 / 100
391 ms1720 KiB
#include <bits/stdc++.h> #include "holiday.h" using namespace std; using ll = long long; const int N = 100010; int lastbest = N; ll solve(int att[], int n, int d) { ll ans = 0, sum = 0; priority_queue<int, vector<int>, greater<int>> val; int bestix = 0; for (int i = 0; i < n && d > 0; ++i, --d) { val.push(att[i]); sum += att[i]; while (val.size() > d) { sum -= val.top(); val.pop(); } if (sum > ans) bestix = i; ans = max(ans, sum); } assert(bestix <= lastbest+1); lastbest = bestix; return ans; } ll findMaxAttraction(int n, int start, int d, int att[]) { if (n > 3000 && start > 0) return -1; ll ans = 0; for (int i = 0; i <= start; ++i) ans = max(ans, solve(&att[start-i], n-start+i, d-i)); if (start > 0) { start = n-start-1; reverse(att, att+n); lastbest = N; // FOR TESTING for (int i = 0; i <= start; ++i) ans = max(ans, solve(&att[start-i], n-start+i, d-i)); } return ans; }

Compilation message (stderr)

holiday.cpp: In function 'll solve(int*, int, int)':
holiday.cpp:17:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while (val.size() > d) {
                ~~~~~~~~~~~^~~
grader.cpp: In function 'int main()':
grader.cpp:7:12: warning: variable 'n_s' set but not used [-Wunused-but-set-variable]
     int i, n_s;
            ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...