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[])
{
long long ans = 0;
for(int l = 0; l <= start; l++)
{
for(int r = start; r < n; r++)
{
int dl = start-l;
int dr = r-start;
if(dl<dr) swap(dl,dr);
int k = dl + 2*dr;
k = d - k;
if(k<=0) break;
vector<int>v;
for(int i = l; i <= r; i++) v.push_back(attraction[i]);
sort(v.begin(),v.end());
long long ch = 0;
for(int i = v.size()-1; i >= max((int)0,(int)v.size()-k); i--) ch += v[i];
ans = max(ans,ch);
}
}
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... |