Submission #299437

#TimeUsernameProblemLanguageResultExecution timeMemory
299437c4ts0upRoller Coaster Railroad (IOI16_railroad)C++17
11 / 100
2043 ms6552 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define ff first #define ss second typedef long long ll; typedef long double ld; const ll INF = 1e17; ll n, d; long long plan_roller_coaster(vector<int> s, vector<int> t) { n = s.size(); vector <pair <ll,ll> > arr; arr.resize(n); for (int i=0; i<n; i++) arr[i] = {(ll)s[i], (ll)t[i]}; sort(arr.begin(), arr.end()); d = INF; do { ll vel = arr[0].ss, currd = 0; for (int i=1; i<n; i++) { currd += max(0LL, vel-arr[i].ff); vel = arr[i].ss; } d = min(currd, d); } while (next_permutation(arr.begin(), arr.end())); return d; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...