# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
374488 | idk321 | Holiday (IOI14_holiday) | C++11 | 5020 ms | 6252 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;
typedef long long ll;
long long int findMaxAttraction(int n, int start, int d, int v[]) {
if (d == 0) return 0;
if (start == 0)
{
ll res = v[0];
int a = 0;
int b = 0;
ll cur = v[0];
multiset<int> sett;
sett.insert(v[0]);
int cost = 1;
for (int i = 1; i < n && i <= d; i++)
{
cost += 2;
cur += v[i];
sett.insert(v[i]);
while (cost > d)
{
cur -= *sett.begin();
sett.erase(sett.begin());
cost--;
}
res = max(res, cur);
}
return res;
} else
{
ll res = v[start];
multiset<int> sett;
ll cur = 0;
for (int i = start; i < n && i - start <= d; i++)
{
cur += v[i];
sett.insert(v[i]);
int cost = i - start + sett.size();
while (cost > d && !sett.empty())
{
cur -= *sett.begin();
sett.erase(sett.begin());
cost--;
}
res = max(res, cur);
multiset<int> csett = sett;
ll ccur = cur;
for (int j = start - 1; j >= 0; j--)
{
ccur += v[j];
csett.insert(v[j]);
int ccost = i - start + start - j + min(i - start, start - j) + csett.size();
while (ccost > d && !csett.empty())
{
ccur -= *csett.begin();
csett.erase(csett.begin());
ccost--;
}
res = max(res, ccur);
}
}
return res;
}
return 0;
}
/*
5 2 2
1000 2 3 4 1000
*/
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... |