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<bits/stdc++.h>
#include"holiday.h"
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define N 100005
long long sum,ans;
priority_queue<long long,vector<long long>,greater<long long>> q;
void add(long long x){
q.push(x);
sum+=x;
}
void upd(int k){
while(!q.empty()&&(int)q.size()>k){
sum-=q.top();
q.pop();
}
}
long long int findMaxAttraction(int n,int st,int d,int a[]){
int i,j;
if(n<=3000){
for(i=0;i<=st;i++){
sum=0;
for(j=i;j<st;j++)add(a[j]);
for(j=st;j<n;j++){
add(a[j]);
upd(d-j+i-min(st-i,j-st));
ans=max(ans,sum);
}
while(!q.empty())q.pop();
}
}
else if(st==0){
sum=0;
for(i=0;i<n;i++){
add(a[i]);
upd(d-i);
ans=max(ans,sum);
}
}
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... |