# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
600355 | amin | Roller Coaster Railroad (IOI16_railroad) | C++14 | 2076 ms | 6732 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 "railroad.h"
#include<bits/stdc++.h>
using namespace std;
long long n,m;
long long an=1e18;
long long a[20],b[20];
void tr(vector<long>v)
{
// cout<<v.size()<<endl;
long long sum=0;
for(long i=0;i<n-1;i++)
{
if((b[v[i]]-a[v[i+1]])>0)
{
// cout<<a[v[i]]<<' '<<b[v[i+1]]<<endl;
sum+=(b[v[i]]-a[v[i+1]]);
}
}
// cout<<endl;
an=min(an,sum);
}
void rec(long o,vector<long>v)
{
if(o==n)
{
tr(v);
return ;
}
for(long i=0;i<n;i++)
{
long p=0;
for(long y=0;y<v.size();y++)
{
if(v[y]==i)
{
p=1;
break;
}
}
if(p==1)
continue;
v.push_back(i);
rec(o+1,v);
v.pop_back();
}
return ;
}
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
n = s.size();
m=t.size();
for(long i=0;i<n;i++)
{
a[i]=s[i];
}
for(long i=0;i<n;i++)
{
b[i]=t[i];
}
rec(0,{});
return an;
}
Compilation message (stderr)
# | 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... |