This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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];
}
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);
while(!pq.empty()) pq.pop();
}
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |