Submission #591418

#TimeUsernameProblemLanguageResultExecution timeMemory
591418FatihSolakRoller Coaster Railroad (IOI16_railroad)C++17
34 / 100
49 ms10684 KiB
#include "railroad.h" #include <bits/stdc++.h> #define N 16 using namespace std; long long dp[(1<<N)][N]; long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { int n = (int) s.size(); for(int i = 0;i<(1<<n);i++){ for(int j = 0;j<n;j++){ dp[i][j] = 2e18; } } for(int i = 0;i<n;i++){ dp[(1<<i)][i] = 0; } for(int mask = 1;mask <(1<<n);mask++){ for(int i = 0;i<n;i++){ if(!(mask & (1<<i)))continue; for(int j = 0;j<n;j++){ if(mask & (1<<j))continue; dp[mask + (1<<j)][j] = min(dp[mask + (1<<j)][j],dp[mask][i] + max(0,t[i] - s[j])); } //cout << mask << " " << i << " " << dp[mask][i] << endl; } } long long ret = 2e18; for(int i = 0;i<n;i++){ ret = min(ret,dp[(1<<n)-1][i]); } return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...