제출 #250472

#제출 시각아이디문제언어결과실행 시간메모리
250472jwvg0425휴가 (IOI14_holiday)C++17
23 / 100
5069 ms2804 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 = 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 < n; 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 - l) <= remain; r++) { now += at[r]; used.push(at[r]); while (used.size() > remain - (r - l)) { 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; }

컴파일 시 표준 에러 (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:53:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             while (used.size() > remain - (r - l))
                    ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...