이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "railroad.h"
#include <bits/stdc++.h>
using namespace std;
// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e9
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MX=16, BIT=(1<<MX);
int n;
ll dp[MX][BIT];
vi s, t;
ll getAns(int x, int bm) {
if(dp[x][bm] != -1) return dp[x][bm];
if(bm == (1<<n)-1) return dp[x][bm]=0;
ll res=INF;
RE(i,n) if((bm&(1<<i))==0) {
res = min(res, max(0,t[x]-s[i])+getAns(i,bm|(1<<i)));
}
return dp[x][bm]=res;
}
ll plan_roller_coaster(vi S, vi T) {
n = S.size();
s=S; t=T;
RE(i,MX) RE(j,BIT) dp[i][j]=-1;
ll res=INF;
RE(i,n) res=min(res, getAns(i,(1<<i)));
return res;
}
# | 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... |