이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// ~ Be Name Khoda ~ //
#include "railroad.h"
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops,Ofast")
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const int maxn = 1e6 + 10;
const int maxn5 = 5e5 + 10;
const int maxnt = 1.2e6 + 10;
const int maxn3 = 1e3 + 10;
const int mod = 1e9 + 7;
const ll inf = 1e18;
ll dp[(1 << 16)][17];
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
int n = (int) s.size();
for(int mask = 1; mask < (1 << n); mask++){
for(int i = 0; i < n; i++) if((mask >> i)&1){
int mask2 = mask ^ (1 << i);
if(mask2 == 0){
dp[mask][i] = 0;
continue;
}
dp[mask][i] = inf;
for(int j = 0; j < n; j++) if((mask2 >> j)&1){
dp[mask][i] = min(dp[mask][i], dp[mask2][j] + max(0, t[j] - s[i]));
//cout << mask << ' ' << mask2 << ' ' << i << ' ' << j << ' ' << dp[mask][i] << ' ' << t[j] << ' ' << s[i] << endl;
}
}
}
ll mn = inf;
for(int i = 0; i < n; i++)
mn = min(mn, dp[(1 << n) - 1][i]);
return mn;
}
# | 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... |