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;
long long int findMaxAttraction(int n, int start, int d, int attraction[]) {
if(d == 0)
return 0;
long long ans = attraction[start];
for(int l = 0 ; l <= start ; l++)
{
multiset <int> st;
long long sum = 0;
for(int i = l ; i <= start ; i++)
{
sum += attraction[i];
st.insert(attraction[i]);
}
int D = d - (start - l);
int sz = st.size();
//cout << st.size() << " WTF " << D << endl;
while(!st.empty() && sz > D)
{
sum -= *st.begin();
st.erase(st.begin());
sz = st.size();
}
ans = max(ans , sum);
//cout << l << " " << start << " : " << D << " " << sum << endl;
for(int r = start + 1 ; r < n ; r++)
{
st.insert(attraction[r]);
sum += attraction[r];
sz = st.size();
D = d - (r - l) - min(r - start , start - l);
while(!st.empty() && sz > D)
{
sum -= *st.begin();
st.erase(st.begin());
sz = st.size();
}
ans = max(ans , sum);
//cout << l << " " << r<< " : " << D << " " << sum << endl;
}
}
return ans;
}
# | 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... |