# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
994841 | SuPythony | Roller Coaster Railroad (IOI16_railroad) | C++17 | 2094 ms | 524288 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 <bits/stdc++.h>
#include "railroad.h"
using namespace std;
typedef long long ll;
vector<vector<pair<int,ll>>> al;
vector<int> vis;
ll c;
int n;
int tot;
ll mn=1e18;
void dfs(int u) {
vis[u]=1;
n++;
if (n==tot) {
mn=min(mn,c);
}
for (auto i: al[u]) {
if (vis[i.first]) continue;
c+=i.second;
dfs(i.first);
c-=i.second;
}
vis[u]=0;
n--;
}
ll plan_roller_coaster(vector<int> s, vector<int> t) {
al.assign(s.size(),vector<pair<int,ll>>());
tot=s.size();
for (int i=0; i<s.size(); i++) {
for (int j=0; j<s.size(); j++) {
if (i==j) continue;
ll w=0;
if (t[i]>s[j]) w=t[i]-s[j];
al[i].push_back({j,w});
}
}
mn=1e18;
for (int i=0; i<s.size(); i++) {
vis.assign(s.size(),0);
c=0;
n=0;
dfs(i);
}
return mn;
};
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... |