# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
67286 | theknife2001 | Holiday (IOI14_holiday) | C++17 | 20 ms | 2552 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;
priority_queue < int , vector < int > , greater < int > > pq;
long long int findMaxAttraction(int n, int start, int d, int a[]) {
if(!d)
return 0;
d--;
int x=d/2;
d-=x*2;
long long ans=0;
for(int i=0;i<=x&&i<n;i++)
{
pq.push(a[i]);
ans+=a[i];
}
long long ret=ans;
for(int i=x+1;i<n&&pq.size();i++)
{
if(!d)
{
ans-=pq.top();
pq.pop();
}
else
d--;
if(pq.size()&&a[i]>pq.top())
{
ans+=a[i]-pq.top();
pq.pop();
ret=max(ans,ret);
pq.push(a[i]);
}
}
return ret;
}
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... |