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;
#define ll long long
int arr[21];
bool visited[21];
int n,d;
ll solve(int i,int d){
if(i<0) return 0;
if(i>=n) return 0;
if(d<=0) return 0;
ll ans=0;
bool ok=true;
for(int j=0;j<n;j++){
ok&=visited[j];
}
if(ok) return 0;
for(int j=0;j<n;j++){
if(i==j) continue;
int cost=abs(i-j);
if(visited[i]){
ans=max(ans,solve(j,d-cost));
}
if(!visited[i]){
visited[i]=1;
ans=max(ans,arr[i]+solve(j,d-cost-1));
visited[i]=0;
}
}
return ans;
}
long long int findMaxAttraction(int _n, int start, int _d, int v[]) {
ll ans = 0;
n=_n;
d=_d;
for(int i=0;i<n;i++){
arr[i]=v[i];
}
memset(visited,false,sizeof(visited));
return solve(start,d);
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... |