Submission #297895

#TimeUsernameProblemLanguageResultExecution timeMemory
297895DovranRoller Coaster Railroad (IOI16_railroad)C++11
11 / 100
2096 ms9644 KiB
#include <bits/stdc++.h> #define N 200009 #define ll long long #define pii pair <ll, ll> #define ff first #define sz() size() #define ss second #define pb push_back using namespace std; ll n; ll vis[N]; ll v[N]; pii p[N]; ll ans=1e18; void f(int x){ if(x==n){ ll sum=0, y=1; for(int i=0; i<n; i++){ if(y>p[v[i]].ff) sum+=y-p[v[i]].ff; y=p[v[i]].ss; } ans=min(ans, sum); return; } for(int i=0; i<n; i++){ if(!vis[i]){ vis[i]=1; v[x]=i; f(x+1); vis[i]=0; } } } ll plan_roller_coaster(vector<int>a, vector<int>b){ n=a.size(); for(int i=0; i<n; i++) p[i]={a[i], b[i]}; f(0); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...