제출 #56631

#제출 시각아이디문제언어결과실행 시간메모리
56631spencercomptonShortcut (IOI16_shortcut)C++17
0 / 100
3 ms588 KiB
#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll c;
vector<ll> l;
vector<ll> d;
vector<ll> pos;
ll dist(int i, int j){
	return abs(pos[i]-pos[j]);
}
long long find_shortcut(int n, std::vector<int> x, std::vector<int> y, int z)
{
	for(int i = 0; i<n; i++){
		if(i!=0){
			l.push_back(x[i]);
		}
		d.push_back(y[i]);
	}
	c = z;
	ll inf = 10000000000000000LL;
	pos.resize(n);
	pos[0] = 0LL;
	for(int i = 1; i<n; i++){
		pos[i] = pos[i-1] + (ll)l[i-1];
	}
	ll best[n];
	int f[n];
	for(int i = 0; i<n; i++){
		best[i] = inf;
		f[i] = -1;
	}
	for(int i = 0; i<n; i++){
		for(int j = i+1; j<n; j++){
			ll now = 0LL;
			for(int a = 0; a<n; a++){
				for(int b = a+1; b<n; b++){
					//a->b

					ll here = min(d[a]+d[b]+dist(a,b),d[a]+d[b]+dist(a,i)+c+dist(j,b));
					now = max(now,here);
				}
			}
			if(now<best[i]){
				best[i] = now;
				f[i] = j;
			}
		}
	}
	ll ans = best[0];
	for(int i = 0; i<n-1; i++){
		ans = min(ans,best[i]);
		assert(f[i]!=-1);
	}
	// ll maxl[n];
	// ll maxr[n];
	// ll dl[n];
	// ll dr[n];
	// int bl[n];
	// int br[n];
	// dl[0] = 0LL;
	// dr[0] = 0LL;
	// bl[0] = 0;
	// br[0] = 0;
	// maxl[0] = d[0];
	// for(int i = 1; i<n; i++){
	// 	maxl[i] = max(maxl[i-1]+(ll)l[i-1],d[i]);
	// }
	// maxr[n-1] = d[n-1];
	// for(int i = n-2; i>=0; i--){
	// 	maxr[i] = max(maxr[i+1]+(ll)l[i],d[i]);
	// }
	// int f[n];
	// ll best[n];
	// for(int i = 0; i<n; i++){
	// 	f[i] = -1;
	// 	best[i] = inf;
	// }
	// for(int i = 0; i<n; i++){
	// 	for(int j = i; j<n; j++){
	// 		//A B C
	// 		//A -> 
	// 	}
	// }
    return ans;
}
/*
4 10
10 20 20
0 40 0 30

*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...