Submission #600356

#TimeUsernameProblemLanguageResultExecution timeMemory
600356aminRoller Coaster Railroad (IOI16_railroad)C++14
11 / 100
2073 ms6744 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 ; } 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)

railroad.cpp: In function 'void rec(long int, std::vector<long int>)':
railroad.cpp:36:13: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         if(r==p.size())
      |            ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...