제출 #568212

#제출 시각아이디문제언어결과실행 시간메모리
568212definitelynotmeeRoller Coaster Railroad (IOI16_railroad)C++98
0 / 100
45 ms10052 KiB
#include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define all(x) x.begin(),x.end() using ll = long long; using pii = pair<int,int>; using pll = pair<ll,ll>; template<typename T> using matrix = vector<vector<T>>; const ll INFL = (1ll<<62); ll plan_roller_coaster(vector<int> s, vector<int>t){ int n = s.size(); matrix<ll> dp(1<<n,vector<ll>(n,INFL)); dp[0][0] = 0; for(int i = 0; i < (1<<n); i++){ for(int j = 0; j < n; j++){ for(int k = 0; k < n; k++){ if(!((1<<k)&i)) continue; dp[i][k] = min(dp[i][k],dp[i^(1<<k)][j]+max(0,t[j]-s[k])); } } } // for(int i = 0; i < (1<<n); i++){ // for(int j = 0; j < n; j++){ // cout <<"dp[" << bitset<3>(i) << "][" << j << "] = " << dp[i][j] << '\n'; // } // } return *min_element(all(dp[(1<<n)-1])); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...