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 <vector>
#include <queue>
using namespace std;
typedef long long ll;
priority_queue < int, vector < int >, greater < int > > q;
ll findMaxAttraction(int n, int x, int d, int l[]){
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++){
q.push(l[j]);
sum+=l[j];
}
while(!q.empty() && d-treba<(int)q.size()){
sum-=q.top();
q.pop();
}
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];
q.push(l[j]);
while(!q.empty() && d-treba<(int)q.size()){
sum-=q.top();
q.pop();
}
sol=max(sol, sum);
}
while(!q.empty()){
q.pop();
}
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... |