# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
757267 | Seb | Roller Coaster Railroad (IOI16_railroad) | C++17 | 2060 ms | 8476 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>
using namespace std;
typedef long long ll;
const ll INF = 1e10;
ll ans = INF;
bool vis[16];
vector <int> v,S,T;
ll n;
void checkeo() {
ll aux=0;
for (int i=1;i<n;i++) aux += max(T[v[i-1]]-S[v[i]],0);
ans = min(ans,aux);
return;
}
void bruta() {
if (!v.empty() && v.size()==n) {
checkeo();
return;
}
for (int i=0;i<n;i++) if (vis[i]==false) {
v.push_back(i);
vis[i] = true;
bruta();
v.pop_back();
vis[i] = false;
}
return;
}
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
n = (int) s.size();
swap(S,s);
swap(T,t);
bruta();
return ans;
}
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... |