Submission #902214

#TimeUsernameProblemLanguageResultExecution timeMemory
902214nguyentunglamRoller Coaster Railroad (IOI16_railroad)C++17
11 / 100
2071 ms8132 KiB
#include<bits/stdc++.h> #define fi first #define se second #define endl "\n" #define ii pair<int, int> using namespace std; long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { int n = (int) s.size(); vector<int> order(n); for(int i = 0; i < n; i++) order[i] = i; auto check = [&] () { long long ret = 0; for(long long cur = 0, speed = 1; cur < n; cur++) { int i = order[cur]; ret += max(0LL, speed - s[i]); speed = t[i]; } return ret; }; long long ans = 1e18; do { ans = min(ans, check()); } while (next_permutation(order.begin(), order.begin() + n)); return ans; } #ifdef ngu int main() { freopen ("task.inp", "r", stdin); freopen ("task.out", "w", stdout); int n; cin >> n; vector<int> s(n), t(n); for(int i = 0; i < n; i++) cin >> s[i] >> t[i]; cout << plan_roller_coaster(s, t); } #endif // ngu
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...