제출 #1064437

#제출 시각아이디문제언어결과실행 시간메모리
1064437YassirSalama휴가 (IOI14_holiday)C++17
0 / 100
5074 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; if(visited[j]) continue; int cost=abs(i-j); if(!visited[i]){ visited[i]=1; ans=max(ans,arr[i]+solve(j,d-cost-1)); visited[i]=0; continue; } ans=max(ans,solve(j,d-cost)); } 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...