# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
165441 | Segtree | Roller Coaster Railroad (IOI16_railroad) | C++14 | 140 ms | 8696 KiB |
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<iostream>
#include<algorithm>
#include<vector>
#include"railroad.h"
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b);
ll dp[(1<<16)][16];
ll plan_roller_coaster(vector<int> s,vector<int> t){
int n=s.size();
for(int i=0;i<(1<<n);i++)for(int j=0;j<n;j++)dp[i][j]=1e17;
for(int j=0;j<n;j++){
dp[(1<<j)][j]=0;
}
for(int i=1;i<(1<<n);i++)for(int j=0;j<n;j++){
for(int k=0;k<n;k++){
if((i&(1<<k))==0)chmin(dp[i+(1<<k)][k],dp[i][j]+max(0LL,(ll)t[j]-s[k]));
}
}
ll ans=1e17;
for(int j=0;j<n;j++)chmin(ans,dp[(1<<n)-1][j]);
return ans;
}
# | 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... |