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 <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); i++)
#define INF (1LL<<60)
int N;
int S[200000], T[200000];
long long dp[1<<16][16];
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
N = s.size();
rep(i, N) S[i] = s[i], T[i] = t[i];
assert(N <= 16);
rep(i, 1<<N) rep(j, N) dp[i][j] = INF;
rep(i, N) dp[1<<i][i] = 0;
rep(b, 1<<N) {
rep(last, N) {
if (dp[b][last] == INF) continue;
rep(t, N) if (((b>>t)&1) == 0) {
dp[b|(1<<t)][t] = min(dp[b|(1<<t)][t], dp[b][last] + max(T[last]-S[t], 0));
}
}
}
long long m = INF;
rep(i, N) m = min(m, dp[(1<<N)-1][i]);
return m;
}
# | 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... |