# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
568205 | 2022-05-24T22:29:27 Z | definitelynotmee | Shortcut (IOI16_shortcut) | C++ | 0 ms | 0 KB |
#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)); 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++){ for(int k = 0; k < n; k++){ if(!(k&i)) continue; dp[i][k] = min(dp[i][k],dp[i^k][j]+max(0,t[j]-s[i])); } } } return *min_element(all(dp[(1<<n)-1])); }