제출 #297878

#제출 시각아이디문제언어결과실행 시간메모리
297878DovranRoller Coaster Railroad (IOI16_railroad)C++11
0 / 100
72 ms7032 KiB
#include <bits/stdc++.h> #define N 200009 #define pii pair <int, int> #define ff first #define sz() size() #define ss second #define pb push_back #define ll long long using namespace std; int n; int vis[N]; int v[N]; pii p[N]; ll ans=0; void f(int x){ if(x==n){ ll sum=0, y=1; for(int i=0; i<n; i++){ if(y>p[i].ff) sum+=y-p[i].ff; y=p[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[x]=0; } } } ll plan_roller_coaster(vector<int>a, vector<int>b){ int 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...