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 "railroad.h"
#include<bits/stdc++.h>
///Subtask 1
using namespace std;
typedef long long ll;
ll sum=0;
ll minimum=LLONG_MAX;
int n;
ll cost[16][16];
int taken[16];
void recursion(int k,int last)
{
if(k==n){
minimum=min(minimum,sum);
return;
}
for(int i=0;i<n;i++){
if(taken[i]) continue;
taken[i]=1;
sum+=cost[last][i];
recursion(k+1,i);
taken[i]=0;
sum-=cost[last][i];
}
}
long long plan_roller_coaster(vector<int> s, vector<int> t) {
n=s.size();
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(j==i) continue;
cost[i][j]=max(0,t[i]-s[j]);
}
}
recursion(0,n);
return minimum;
}
# | 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... |