# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1017224 | simona1230 | Holiday (IOI14_holiday) | C++17 | 5037 ms | 2520 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;
int a[100001],n,s,d;
long long ans;
priority_queue<int> q;
void solve()
{
for(int l=0;l<=s;l++)
{
while(q.size())q.pop();
long long curr=0;
for(int i=l;i<s;i++)
{
q.push(-a[i]);
curr+=a[i];
if(q.size()>d)
{
curr-=(-q.top());
q.pop();
}
}
for(int i=s;i<n;i++)
{
q.push(-a[i]);
curr+=a[i];
int days=d-(i-l+1+min(i-s,s-l));
if(days<0)break;
if(q.size()>days)
{
curr-=(-q.top());
q.pop();
}
ans=max(ans,curr);
}
}
}
long long int findMaxAttraction(int N, int start, int D, int attraction[])
{
n=N;
d=D;
s=start;
for(int i=0;i<n;i++)
a[i]=attraction[i];
solve();
return ans;
}
Compilation message (stderr)
# | 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... |