제출 #416994

#제출 시각아이디문제언어결과실행 시간메모리
416994yuto1115Roller Coaster Railroad (IOI16_railroad)C++17
34 / 100
54 ms11072 KiB
#include "railroad.h" #include <bits/stdc++.h> #define rep(i, n) for(ll i = 0; i < ll(n); i++) #define rep2(i, s, n) for(ll i = ll(s); i < ll(n); i++) #define rrep(i, n) for(ll i = ll(n)-1; i >= 0; i--) #define pb push_back #define eb emplace_back #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() using namespace std; using ll = long long; using P = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vp = vector<P>; using vvp = vector<vp>; using vb = vector<bool>; using vvb = vector<vb>; using vs = vector<string>; template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } const int inf = 1001001001; const ll linf = 1001001001001001001; ll plan_roller_coaster(vi s, vi t) { int n = s.size(); assert(n <= 16); vvl dp(1 << n, vl(n, linf)); rep(i, n) dp[1 << i][i] = 0; rep(i, 1 << n) rep(j, n) { if (~i >> j & 1) continue; rep(k, n) { if (i >> k & 1) continue; chmin(dp[i | 1 << k][k], dp[i][j] + max(0, t[j] - s[k])); } } ll ans = linf; rep(i, n) chmin(ans, dp[(1 << n) - 1][i]); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...