제출 #598426

#제출 시각아이디문제언어결과실행 시간메모리
598426PyishtellRoller Coaster Railroad (IOI16_railroad)C++17
0 / 100
49 ms10584 KiB
#include "railroad.h" #include <bits/stdc++.h> typedef long long ll; using namespace std; ll plan_roller_coaster(std::vector<int> s, std::vector<int> t) { int n = (int) s.size(); ll way = pow(2,n); ll dp[way][n] = {1000000000000000000}; for(ll i=0; i<way; i++){ for(ll j=0; j<n; j++){ if(i/int(pow(2,j))==1 && i%int(pow(2,j))==0) dp[i][j] = 0; else if((i/int(pow(2,j)))%2==1){ ll a = i-pow(2,j); for(int k=0; k<n; k++){ if((a/int(pow(2,k)))%2==1){ dp[i][j] = min(dp[a][k]+max(0,t[j]-s[k]),dp[i][j]); } } } } } ll ans=dp[way-1][0]; for(int i=0; i<n; i++){ ans = min(dp[way-1][i],ans); } 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...