제출 #66595

#제출 시각아이디문제언어결과실행 시간메모리
66595aquablitz11휴가 (IOI14_holiday)C++14
23 / 100
146 ms1776 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); // FOR TESTING 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); for (int i = 0; i <= start; ++i) ans = max(ans, solve(&att[start-i], n-start+i, d-i)); } return ans; }

컴파일 시 표준 에러 (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...