# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
226710 | urd05 | 휴가 (IOI14_holiday) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n;
int st;
int d;
long long arr[100000];
long long findMaxAttraction(int nn,int start,int dd,long long at[]) {
n=nn;
st=start;
d=dd;
for(int i=0;i<n;i++) {
arr[i]=at[i];
}
long long ret=0;
long long sum=0;
priority_queue<long long,vector<long long>,greater<long long>> pq;
for(int i=st;i>=0;i--) {
while (!pq.empty()) {
pq.pop();
}
sum=0;
for(int j=i;j<n;j++) {
pq.push(arr[j]);
sum+=arr[j];
while ((int)pq.size()>d-st-j+2*i&&!pq.empty()) {
sum-=pq.top();
pq.pop();
}
ret=max(ret,sum);
}
}
for(int i=st;i<n;i++) {
while (!pq.empty()) {
pq.pop();
}
sum=0;
for(int j=i;j>=0;j--) {
pq.push(arr[j]);
sum+=arr[j];
while ((int)pq.size()>d+j+st-2*i&&!pq.empty()) {
sum-=pq.top();
pq.pop();
}
}
ret=max(ret,sum);
}
return ret;
}