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>
using namespace std;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif
long long plan_roller_coaster(vector<int> s, vector<int> t) {
    int n = (int) s.size();
    const long long inf = (long long) 1e18;
    vector<vector<long long>> dp(1 << n, vector<long long>(n, inf));
    for (int i = 0; i < n; i++) {
        dp[1 << i][i] = 0;
    }
    for (int mask = 1; mask < (1 << n); mask++) {
        for (int i = 0; i < n; i++) {
            if (~mask & (1 << i)) {
                continue;
            }
            for (int j = 0; j < n; j++) {
                if (mask & (1 << j)) {
                    continue;
                }
                int nmask = mask | (1 << j);
                dp[nmask][j] = min(dp[nmask][j], dp[mask][i] + max(0, t[i] - s[j]));
            }
        }
    }
    return *min_element(dp.back().begin(), dp.back().end());
}
#ifdef tabr
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    debug(plan_roller_coaster({1, 4, 5, 6}, {7, 3, 8, 6}));
    return 0;
}
#endif
| # | 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... |