# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
430038 | Rouge_Hugo | Holiday (IOI14_holiday) | C++14 | 5082 ms | 5248 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<bits/stdc++.h>
#include"holiday.h"
#define ll long long
#define fi first
#define se second
#define pb push_back
using namespace std;
multiset<ll>s;
long long int findMaxAttraction(int n, int start, int d, int a[])
{
ll mx=0;
if(d>=1)
mx=a[start];
for(int i=start; i<n; i++)
{
int r=d;
ll ans=0;
s.clear();s.insert(a[start]);ans=a[start];
for(int j=start+1;j<=i;j++)
{
r-=2;
if(r<=0)break;
ans+=a[j];
s.insert(a[j]);
while(s.size()>r)
{
ans-=*s.begin();
s.erase(s.begin());
}
mx=max(mx,ans);
}
for(int j=start-1; j>-1; j--)
{
r--;
if(r<=0)
break;
s.insert(a[j]);
ans+=a[j];
if(r<=0)
break;
while(s.size()>r)
{
ans-=*s.begin();
s.erase(s.begin());
}
mx=max(mx,ans);
}
}
for(int i=start; i<n; i++)
{
int r=d;
ll ans=0;
s.clear();s.insert(a[start]);ans=a[start];
for(int j=start+1;j<=i;j++)
{
r--;
if(r<=0)break;
ans+=a[j];
s.insert(a[j]);
while(s.size()>r)
{
ans-=*s.begin();
s.erase(s.begin());
}
mx=max(mx,ans);
}
for(int j=start-1; j>-1; j--)
{
r-=2;
if(r<=0)
break;
s.insert(a[j]);
ans+=a[j];
if(r<=0)
break;
while(s.size()>r)
{
ans-=*s.begin();
s.erase(s.begin());
}
mx=max(mx,ans);
}
}
return mx;
}
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... |