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 <cmath>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
ll findMaxAttraction(int n, int x, int d, int l[]){
multiset < int > s;
int treba;
ll sum=0, sol=0;
for(int i=0; i<=x; i++){
treba=x-i;
if(treba>=d){
continue;
}
for(int j=i; j<=x; j++){
s.insert(l[j]);
sum+=l[j];
}
while(d-treba<(int)s.size()){
sum-=*s.begin();
s.erase(s.begin());
}
sol=max(sol, sum);
for(int j=x+1; j<n; j++){
treba=min(j-x, x-i)*2+max(j-x, x-i);
sum+=l[j];
s.insert(l[j]);
while(d-treba<(int)s.size()){
sum-=*s.begin();
s.erase(s.begin());
}
sol=max(sol, sum);
}
s.clear();
sum=0;
}
return sol;
}
# | 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... |