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++)
{
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;
vector<int>v;
priority_queue<City>q;
int br = 0;
long long ch = 0;
for(int i = l; i <= r; i++)
{
if(br<k)
{
br++;
ch += attraction[i];
q.push(attraction[i]);
}
else
{
if(attraction[i]<=q.top().attr) continue;
q.push(attraction[i]);
ch += attraction[i];
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... |