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(d<=0) return 0;
ll ans=0;
for(int j=0;j<n;j++){
if(i==j) continue;
if(visited[j]) continue;
visited[i]=1;
ans=max(ans,arr[i]+solve(j,d-abs(i-j)-1));
ans=max(ans,solve(i,d-abs(i-j)));
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... |