Submission #600359

#TimeUsernameProblemLanguageResultExecution timeMemory
600359aminRoller Coaster Railroad (IOI16_railroad)C++14
11 / 100
2087 ms6720 KiB
#include "railroad.h" #include<bits/stdc++.h> using namespace std; long long n,m; long long an=1e18; long long a[20],b[20],j[20]; void tr(vector<long>v) { for(long i=0;i<n;i++) { j[i]=0; } for(long i=0;i<n;i++) { j[v[i]]++; if(j[v[i]]>1) return ; } // 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); return ; } void rec(long o,vector<long>v) { if(o==n) { tr(v); return ; } long r=0; for(long i=0;i<n;i++) { 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)

railroad.cpp: In function 'void rec(long int, std::vector<long int>)':
railroad.cpp:44:10: warning: unused variable 'r' [-Wunused-variable]
   44 |     long r=0;
      |          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...