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 <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
typedef priority_queue<ll> pq;
ll a[100000];
ll b[100000];
ll f(int L,int R,int cnt){
pq Q;
for(int i=L;i<=R;i++){
Q.push(a[i]);
}
ll sum=0;
for(int i=0;i<cnt;i++){
if(Q.empty())return sum;
sum+=Q.top();
Q.pop();
}
return sum;
}
ll findMaxAttraction(int n, int start, int d, int attraction[]){
for(int i=0;i<n;i++){
a[i]=attraction[i];
}
for(int i=start;i<n;i++){
for(int j=start;(start-j)*2+(i-start)<=d;j--){
if(j<0)break;
b[i]=max(b[i],f(j,i,d-(start-j)*2-(i-start)));
}
}
for(int i=start;i>=0;i--){
for(int j=start;(j-start)*2+(start-i)<=d;j++){
if(j>=n)break;
b[i]=max(b[i],f(i,j,d-(j-start)*2-(start-i)));
}
}
ll ans=0;
for(int i=0;i<n;i++)ans=max(ans,b[i]);
return ans;
}
# | 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... |