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 <bits/stdc++.h>
using namespace std;
struct City
{
int attr;
City(){};
City(int ai)
{
attr = ai;
}
bool operator<(const City &ed) const
{
return attr > ed.attr;
}
};
long long int findMaxAttraction(int n, int start, int d, int attraction[])
{
long long ans = 0;
for(int l = 0; l <= start; l++)
{
priority_queue<City>q;
int br = 0;
long long ch = 0;
for(int i = l; i < start; i++)
{
br++;
ch += attraction[i];
q.push(attraction[i]);
}
for(int r = start; r < n; r++)
{
int dl = start-l;
int dr = r-start;
if(dl<dr) swap(dl,dr);
int k = dl + 2*dr;
k = d - k;
if(k<=0) break;
while(br>k)
{
br--;
ch -= q.top().attr;
q.pop();
}
if(br<k)
{
br++;
ch += attraction[r];
q.push(attraction[r]);
}
else
{
if(attraction[r]<=q.top().attr) continue;
q.push(attraction[r]);
ch += attraction[r];
ch -= q.top().attr;
q.pop();
}
ans = max(ans,ch);
}
while(!q.empty()) q.pop();
}
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... |