Submission #132933

#TimeUsernameProblemLanguageResultExecution timeMemory
132933wzyRoller Coaster Railroad (IOI16_railroad)C++11
34 / 100
83 ms12152 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; ll dp[1<<17][17]; vector<int> s , t; long long plan_roller_coaster(std::vector<int> sx, std::vector<int> tx){ int n = (int) sx.size(); s = sx , t = tx; for(int i = 0 ; i < (1<<n) ; i ++){ for(int j = 0 ; j < n; j ++){ dp[i][j] = (ll) 1e18; } } for(int i = 0 ; i < n;i ++){ dp[1<<i][i] = 0; } for(int i = 0 ; i < (1<<n) ; i ++){ for(int j = 0 ; j < n ; j ++){ if((1<<j) & i){ for(int k = 0 ; k < n ; k++){ if((1<<k) & (i^(1<<j))){ if(dp[i][j] > (dp[i^(1<<j)][k] + (ll)max(t[k] - s[j] , 0))){ dp[i][j] = min(dp[i][j] , dp[i^(1<<j)][k] + (ll)max(t[k] - s[j] , 0)); } } } } } } int L = (1<<n); L--; ll p = (ll) 1e18; for(int j = 0 ; j < n ; j ++){ p = min(p , dp[L][j]); } return p; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...