이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T>
using matrix = vector<vector<T>>;
const ll INFL = (1ll<<62);
ll plan_roller_coaster(vector<int> s, vector<int>t){
int n = s.size();
matrix<ll> dp(1<<n,vector<ll>(n,INFL));
fill(all(dp[0]),0);
for(int i = 0; i < (1<<n); i++){
for(int j = 0; j < n; j++){
for(int k = 0; k < n; k++){
if(!((1<<k)&i))
continue;
dp[i][k] = min(dp[i][k],dp[i^(1<<k)][j]+max(0,t[j]-s[k]));
}
}
}
return *min_element(all(dp[(1<<n)-1]));
}
# | 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... |