# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
262506 | amalla | Roller Coaster Railroad (IOI16_railroad) | C++17 | 390 ms | 524292 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;
int N;
vector<int> S, T;
vector<vector<long long> > memo((1<<16)+20, vector<long long>(17) );
vector<vector<bool> > vis((1<<16)+20, vector<bool>(17, false) );
long long DP(int mask, int curr) {
if (__builtin_popcount(mask) == N) return 0;
if (vis[mask][curr]) return memo[mask][curr];
long long ans = 1000000000000000000;
for (int i = 0; i<N; ++i) {
if (i&(mask)) continue;
if (T[curr]>S[i]) ans = min(ans, DP( mask|1<<i, i) + T[curr]-S[i] );
else ans = ans = min(ans, DP( mask|1<<i, i) );
}
memo[mask][curr] = ans;
vis[mask][curr] = true;
return memo[mask][curr];
}
long long plan_roller_coaster(vector<int> s, vector<int> t) {
N = (int) s.size();
S = s;
T = t;
return DP(0,1);
}
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... |