Submission #429092

#TimeUsernameProblemLanguageResultExecution timeMemory
429092TangentRoller Coaster Railroad (IOI16_railroad)C++17
0 / 100
2082 ms9700 KiB
#include "railroad.h" #include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vii; typedef vector<ll> vll; typedef vector<pii> vpii; typedef vector<pll> vpll; typedef vector<vii> vvii; typedef vector<vll> vvll; typedef vector<vpii> vvpii; typedef vector<vpll> vvpll; #define ffor(i, a, b) for (ll i = (a); i < (ll)(b); i++) #define fford(i, a, b) for (ll i = (a); i > (ll)(b); i--) #define rep(i, n) ffor(i, 0, n) #define forin(x, a) for (auto &x: a) #define all(a) a.begin(), a.end() long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { int n = (int) s.size(); ll res = 1LL << 62; vii used(n); ll curr = 0; function<void(int)> dfs; dfs = [&](int p) { int speed; if (p == -1) { speed = 1; } else { speed = t[p]; } if (curr > res) { return; } bool found = false; rep(i, n) { if (!used[i]) { found = true; if (t[i] < speed || p == -1 || max(0, speed - s[i]) <= max(0, t[i] - s[p])) { used[i] = true; curr += max(0, speed - s[i]); dfs(i); curr -= max(0, speed - s[i]); used[i] = false; } } } if (!found) { res = min(res, curr); } }; dfs(-1); return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...