Submission #250475

#TimeUsernameProblemLanguageResultExecution timeMemory
250475jwvg0425Holiday (IOI14_holiday)C++17
47 / 100
5047 ms2856 KiB
#include"holiday.h" #include <queue> #include <algorithm> #define all(x) (x).begin(), (x).end() using namespace std; long long int fromZero(int n, int d, int attraction[]) { priority_queue<int, vector<int>, greater<int>> q; long long int now = 0; long long int ans = 0; for (int i = 0; i < n; i++) { // 0 -> i까지 간다고 했을 때 관광지 방문에 쓸 수 있는 날짜 int canVisit = max(0, d - i); now += attraction[i]; q.push(attraction[i]); while (q.size() > canVisit) { now -= q.top(); q.pop(); } ans = max(ans, now); } return ans; } // start -> l -> r 순으로 돌아다니는걸 가정 long long int solve(const vector<int> at, int start, int d) { long long int ans = 0; int n = at.size(); for (int l = 0; l <= start; l++) { priority_queue<int, vector<int>, greater<int>> used; long long int now = 0; int remain = d - (start - l); for (int r = l; r < n; r++) { now += at[r]; used.push(at[r]); int canVisit = max(0, remain - (r - l)); while (used.size() > canVisit) { now -= used.top(); used.pop(); } ans = max(ans, now); } } return ans; } long long int findMaxAttraction(int n, int start, int d, int attraction[]) { if (start == 0) return fromZero(n, d, attraction); vector<int> at(n); for (int i = 0; i < n; i++) at[i] = attraction[i]; long long int ans = solve(at, start, d); reverse(all(at)); start = n - 1 - start; ans = max(ans, solve(at, start, d)); return ans; }

Compilation message (stderr)

holiday.cpp: In function 'long long int fromZero(int, int, int*)':
holiday.cpp:23:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while (q.size() > canVisit)
                ~~~~~~~~~^~~~~~~~~~
holiday.cpp: In function 'long long int solve(std::vector<int>, int, int)':
holiday.cpp:55:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             while (used.size() > canVisit)
                    ~~~~~~~~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...