Submission #352616

#TimeUsernameProblemLanguageResultExecution timeMemory
352616amunduzbaevRoller Coaster Railroad (IOI16_railroad)C++14
34 / 100
65 ms13932 KiB
#include "railroad.h" #ifndef EVAL #include "grader.cpp" #endif #include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define pb push_back #define mp make_pair #define ub upper_bound #define lb lower_bound #define ll long long #define ld long double #define pii pair<int, int> #define pll pair<ll, ll> #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(),x.rend() #define fastios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define vll vector<ll> #define vii vector<int> #define vpii vector<pii> #define vpll vector<pll> #define cnt(a)__builtin_popcount(a) template<class T> bool umin(T& a, const T& b) {return a > b? a = b, true:false;} template<class T> bool umax(T& a, const T& b) {return a < b? a = b, true:false;} const ll inf = 1e18+7; const int N = 2e5+5; vii s, t; int n; ll dp[(1<<16)][16]; long long plan_roller_coaster(vector<int> S, vector<int> T) { n = sz(S); s.resize(n); t.resize(n); for(int i=0;i<n;i++) s[i] = S[i]; for(int i=0;i<n;i++) t[i] = T[i]; for(int i=0;i<(1<<n);i++){ for(int j=0;j<n;j++) dp[i][j] = inf; } 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(i>>j & 1){ ll tt = (i ^ (1<<j)); for(int l=0;l<n;l++){ if(tt >> l & 1) dp[i][j] = min(dp[i][j], dp[tt][l] + (t[l] < s[j] ? 0:t[l] - s[j])); } } } } ll mn = inf; for(int i=0;i<n;i++){ umin(mn, dp[(1<<n)-1][i]); } return mn; } /* 4 1 7 4 3 5 8 6 6 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...