Submission #165441

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
1654412019-11-27 09:29:59SegtreeRoller Coaster Railroad (IOI16_railroad)C++14
34 / 100
140 ms8696 KiB
#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;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...