Submission #15703

#TimeUsernameProblemLanguageResultExecution timeMemory
15703gs14004휴가 (IOI14_holiday)C++14
23 / 100
5000 ms3408 KiB
#include"holiday.h" #include <cstdio> #include <queue> using namespace std; typedef long long lint; priority_queue<int, vector<int>, greater<int> > pq; int opt[100005]; long long int findMaxAttraction(int n, int start, int d, int attraction[]) { lint ret = 0; int beforeMax = 0; for(int i=0; i<=start; i++){ lint cret = 0; lint pcret = 0; int pos = 0; for(int j=i; j<start; j++){ pq.push(attraction[j]); cret += attraction[j]; } pcret = cret; for(int j=start; j<n; j++){ pq.push(attraction[j]); cret += attraction[j]; while(!pq.empty() && (int)pq.size() > d - (j - i + min(j - start, start - i) )){ cret -= pq.top(); pq.pop(); } if(j >= beforeMax && cret >= pcret){ pcret = cret; beforeMax = j; } } while(!pq.empty()) pq.pop(); cret = 0; for(int j=i; j<=beforeMax; j++){ pq.push(attraction[j]); cret += attraction[j]; while(!pq.empty() && (int)pq.size() > d - (j - i + min(j - start, start - i) )){ cret -= pq.top(); pq.pop(); } } ret = max(ret, cret); } return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...