# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
729044 | grogu | Roller Coaster Railroad (IOI16_railroad) | C++14 | 2067 ms | 12024 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "railroad.h"
#include <bits/stdc++.h>
#define endl '\n'
#define here cerr<<"=========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#define ll long long
#define pb push_back
#define popb pop_back
#define all(a_) a_.begin(),a_.end()
#define pll pair<ll,ll>
#define sc second
#define fi first
#define llinf 1000000000000000LL
using namespace std;
#define maxn 200005
ll n;
pll a[maxn];
long long plan_roller_coaster(vector<int> s, vector<int> t) {
n = s.size();
for(ll i = 1;i<=n;i++) a[i] = {t[i-1],s[i-1]};
if(n<=8){
vector<ll> v(n);
iota(all(v),1);
ll ans = llinf;
do{
ll cur = 0;
for(ll i = 0;i<v.size()-1;i++){
cur += max(0LL,a[v[i]].fi-a[v[i+1]].sc);
}
ans = min(ans,cur);
}while(next_permutation(all(v)));
return ans;
}
}
/**
4
1 7
4 3
5 8
6 6
**/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |