이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"holiday.h"
#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long lint;
priority_queue<int, vector<int>, greater<int> > pq;
lint ret;
int *a, st, dist;
void divConq(int s, int e, int rs, int re){ // boilerplate
if(s > e) return;
int m = (s+e)/2;
lint copt = 0, cres = -1;
int opt = 0;
for(int i=m; i<rs; i++){
pq.push(a[i]);
copt += a[i];
}
for(int i=rs; i<=re; i++){
pq.push(a[i]);
copt += a[i];
while(!pq.empty() && (int)pq.size() > dist - (i - m + min(i - st, st - m) )){
copt -= pq.top();
pq.pop();
}
if(cres < copt){
cres = copt;
opt = i;
}
}
ret = max(ret, cres);
while(!pq.empty()) pq.pop();
divConq(s,m-1,rs,opt);
divConq(m+1,e,opt,re);
}
long long int findMaxAttraction(int n, int start, int d, int attraction[]) {
a = attraction;
st = start;
dist = d;
divConq(0, start, start, n-1);
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... |