# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
600356 | amin | Roller Coaster Railroad (IOI16_railroad) | C++14 | 2073 ms | 6744 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 ;
}
vector<long>p=v;
sort(p.begin(),p.end());
long r=0;
for(long i=0;i<n;i++)
{
if(r==p.size())
{
v.push_back(i);
rec(o+1,v);
v.pop_back();
continue;
}
if(p[r]==i)
{
r++;
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... |