Submission #1064436

#TimeUsernameProblemLanguageResultExecution timeMemory
1064436YassirSalamaHoliday (IOI14_holiday)C++17
0 / 100
5087 ms2140 KiB
#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]){ if(visited[j]) continue; ans=max(ans,solve(j,d-cost)); } if(!visited[i]){ if(visited[j]) continue; 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...