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"
#define FOR(i,p,k) for(int i=(p);i<=(k);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define inf 1000000000000000000ll
using namespace std;
typedef long long ll;
ll plan_roller_coaster(vector<int> s, vector<int> t) {
int n = s.size();
vector<vector<ll>> dp(1<<n, vector<ll>(n, inf));
FOR(maska, 1, (1<<n)-1) REP(ost, n) if(maska>>ost&1){
if(__builtin_popcount(maska) == 1) dp[maska][ost] = 0ll;
REP(i, n) if(!(maska>>i&1)) dp[maska+(1<<i)][i] = min(dp[maska+(1<<i)][i], dp[maska][ost] + max(0, t[ost]-s[i]));
}
ll wyn = inf;
REP(i, n) wyn = min(wyn, dp[(1<<n)-1][i]);
return wyn;
}
# | 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... |