Submission #600355

#TimeUsernameProblemLanguageResultExecution timeMemory
600355aminRoller Coaster Railroad (IOI16_railroad)C++14
11 / 100
2076 ms6732 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]; 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)

railroad.cpp: In function 'void rec(long int, std::vector<long int>)':
railroad.cpp:34:23: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         for(long y=0;y<v.size();y++)
      |                      ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...