Submission #223028

#TimeUsernameProblemLanguageResultExecution timeMemory
223028DavidDamianRoller Coaster Railroad (IOI16_railroad)C++11
11 / 100
2090 ms10616 KiB
#include "railroad.h" #include<bits/stdc++.h> ///Subtask 1 using namespace std; typedef long long ll; ll sum=0; ll minimum=LLONG_MAX; int n; ll cost[16][16]; int taken[16]; void recursion(int k,int last) { if(k==n){ minimum=min(minimum,sum); return; } for(int i=0;i<n;i++){ if(taken[i]) continue; taken[i]=1; sum+=cost[last][i]; recursion(k+1,i); taken[i]=0; sum-=cost[last][i]; } } long long plan_roller_coaster(vector<int> s, vector<int> t) { n=s.size(); for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(j==i) continue; cost[i][j]=max(0,t[i]-s[j]); } } recursion(0,n); return minimum; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...