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;
const long long INF = 2e18;
long long plan_roller_coaster(vector<int> s, vector<int> t){
int n = (int)s.size();
if(n <= 16){
long long dist[1 << n][n];
for(int m = 0; m < (1 << n); m++) fill(dist[m], dist[m] + n, INF);
for(int i = 0; i < n; i++) dist[1 << i][i] = 0;
for(int m = 1; m < (1 << n); m++){
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(!(m & (1 << j))){
dist[m | (1 << j)][j] = min(dist[m | (1 << j)][j], dist[m][i] + max(0, t[i] - s[j]));
}
}
}
}
return *min_element(dist[(1 << n) - 1], dist[(1 << n) - 1] + n);
}
return 0;
}
# | 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... |