#include "railroad.h"
#include <bits/stdc++.h>
using namespace std;
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
int n = (int) s.size();
vector<vector<long long>> dp((1<<n), vector<long long>(n,1e16));
long long kk=1;
int kkpos=0;
while(kkpos<n)
{
dp[kk][kkpos]=0;
kk=kk*2;
kkpos++;
}
for(int i=0;i<(1<<n);i++)
{
for(int j=0;j<n;j++)
{
if(((1<<j) & i)==0)
{
for(int k=0;k<n;k++)
{
if(((1<<k) & i)!=0)
{
long long distance=max((t[k]-s[j]),0);
dp[i | (1<<j)][j]=min(dp[i | (1<<j)][j],(dp[i][k] + distance));
}
}
}
}
}
long long minnimum=1e16;
for(int j=0;j<n;j++)
{
minnimum=min(minnimum,dp[1<<n][j]);
}
return minnimum;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
300 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
300 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
42 ms |
11172 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
300 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |