Submission #429094

#TimeUsernameProblemLanguageResultExecution timeMemory
429094LouayFarahRoller Coaster Railroad (IOI16_railroad)C++14
11 / 100
2064 ms5556 KiB
#include "bits/stdc++.h" #include "railroad.h" using namespace std; #define pb push_back #define mp make_pair #define fi first #define se second long long plan_roller_coaster(vector<int> s, vector<int> t) { int n = (int)s.size(); if(n<=16) { vector<int> pos(n); for(int i = 0; i<n; i++) pos[i] = i; long long res = 1e18; do { int speed = 1; long long curr = 0; for(int i = 0; i<n; i++) { if(speed>s[pos[i]]) curr+=speed-s[pos[i]]; speed = t[pos[i]]; } res = min(res, curr); }while(next_permutation(pos.begin(), pos.end())); return res; } vector<pair<int, int>> p; for(int i =0; i<n;i++) p.pb(mp(t[i], s[i])); sort(p.begin(), p.end()); long long res = 1; int speed = 1; for(int i = 0; i<n; i++) { if(speed>p[i].se) { res = 0; break; } speed = p[i].fi; } 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...