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;
using ll = long long;
ll D[1<<16][16];
ll plan_roller_coaster(vector<int> s, vector<int> t) {
int n = s.size(); memset(D,63,sizeof(D));
for(int i = 0; i < n; i++) D[1<<i][i]=0;
for(int m = 1; m < (1<<n); m++)
for(int i = 0; i < n; i++) if(m>>i&1)
for(int j = 0; j < n; j++) if(m>>j&1 and j!=i)
D[m][i] = min(D[m][i], D[m^1<<i][j]+(ll)max(0,t[j]-s[i]));
return *min_element(D[(1<<n)-1],D[(1<<n)-1]+n);
}
# | 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... |