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<algorithm>
#include<vector>
#define ll long long
using namespace std;
long long int findMaxAttraction(int n, int start, int d, int attraction[]) {
if(d==0) return 0LL;
ll ans=0;
for(int l=max(0,start-d+1);l<=start;l++){
vector<int>a;
for(int r=l;r<n;r++){
int k=(r-start)+(start-l)+min(r-start,start-l);
if(k>=d) break;
a.push_back(attraction[r]);
if(r>=start){
sort(a.begin(),a.end());
ll cur=0;
for(int i=a.size()-1;i>=max(0,(int)a.size()-(d-k));i--) cur+=a[i];
ans=max(ans,cur);
}
}
}
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... |