Submission #729044

#TimeUsernameProblemLanguageResultExecution timeMemory
729044groguRoller Coaster Railroad (IOI16_railroad)C++14
11 / 100
2067 ms12024 KiB
#include "railroad.h" #include <bits/stdc++.h> #define endl '\n' #define here cerr<<"=========================================\n" #define dbg(x) cerr<<#x<<": "<<x<<endl; #define ll long long #define pb push_back #define popb pop_back #define all(a_) a_.begin(),a_.end() #define pll pair<ll,ll> #define sc second #define fi first #define llinf 1000000000000000LL using namespace std; #define maxn 200005 ll n; pll a[maxn]; long long plan_roller_coaster(vector<int> s, vector<int> t) { n = s.size(); for(ll i = 1;i<=n;i++) a[i] = {t[i-1],s[i-1]}; if(n<=8){ vector<ll> v(n); iota(all(v),1); ll ans = llinf; do{ ll cur = 0; for(ll i = 0;i<v.size()-1;i++){ cur += max(0LL,a[v[i]].fi-a[v[i+1]].sc); } ans = min(ans,cur); }while(next_permutation(all(v))); return ans; } } /** 4 1 7 4 3 5 8 6 6 **/

Compilation message (stderr)

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:27:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |             for(ll i = 0;i<v.size()-1;i++){
      |                          ~^~~~~~~~~~~
railroad.cpp:34:1: warning: control reaches end of non-void function [-Wreturn-type]
   34 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...