# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
51906 | zetapi | Holiday (IOI14_holiday) | C++14 | 0 ms | 0 KiB |
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;
#define pb push_back
#define mp make_pair
#define ll long long
#define itr ::iterator
typedef pair<int,int> pii;
const int MAX=1e5;
vector<int> attractions;
int N;
ll findMaxAttraction(int n=5, int start=2, int d=7,int attraction[])
{
priority_queue<int,vector<int>,greater<int>> pq;
int N=n;
ll sum=0,res=0,left=d;
for(int A=0;A<N;A++)
attractions.pb(attraction[A]);
for(int A=start;A>=0;A--)
{
while(!pq.empty())
pq.pop();
sum=0;
left=d;
for(int B=start;B>=A;B--)
{
if(left<=0)
break;
sum+=attractions[B];
pq.push(attractions[B]);
while(pq.size()>left)
{
sum-=pq.top();
pq.pop();
}
res=max(res,sum);
left--;
}
left++;
if(left<=0)
break;
res=max(res,sum);
if(A==start)
left--;
else
left-=2;
for(int B=start+1;B<N;B++)
{
if(left<=0)
break;
sum+=attractions[B];
pq.push(attractions[B]);
while(pq.size()>left)
{
sum-=pq.top();
pq.pop();
}
res=max(res,sum);
if(B-start<start-A)
left-=2;
else
left--;
}
}
return res;
}
/*signed main()
{
ios_base::sync_with_stdio(false);
cout<<findMaxAttraction()<<"\n";
return 0;
}*/