Submission #56631

# Submission time Handle Problem Language Result Execution time Memory
56631 2018-07-12T04:00:07 Z spencercompton Shortcut (IOI16_shortcut) C++17
0 / 100
3 ms 588 KB
#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 time Memory Grader output
1 Correct 2 ms 504 KB n = 4, 80 is a correct answer
2 Correct 2 ms 532 KB n = 9, 110 is a correct answer
3 Correct 3 ms 588 KB n = 4, 21 is a correct answer
4 Incorrect 2 ms 588 KB n = 3, incorrect answer: jury 4 vs contestant 3
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB n = 4, 80 is a correct answer
2 Correct 2 ms 532 KB n = 9, 110 is a correct answer
3 Correct 3 ms 588 KB n = 4, 21 is a correct answer
4 Incorrect 2 ms 588 KB n = 3, incorrect answer: jury 4 vs contestant 3
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB n = 4, 80 is a correct answer
2 Correct 2 ms 532 KB n = 9, 110 is a correct answer
3 Correct 3 ms 588 KB n = 4, 21 is a correct answer
4 Incorrect 2 ms 588 KB n = 3, incorrect answer: jury 4 vs contestant 3
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB n = 4, 80 is a correct answer
2 Correct 2 ms 532 KB n = 9, 110 is a correct answer
3 Correct 3 ms 588 KB n = 4, 21 is a correct answer
4 Incorrect 2 ms 588 KB n = 3, incorrect answer: jury 4 vs contestant 3
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB n = 4, 80 is a correct answer
2 Correct 2 ms 532 KB n = 9, 110 is a correct answer
3 Correct 3 ms 588 KB n = 4, 21 is a correct answer
4 Incorrect 2 ms 588 KB n = 3, incorrect answer: jury 4 vs contestant 3
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB n = 4, 80 is a correct answer
2 Correct 2 ms 532 KB n = 9, 110 is a correct answer
3 Correct 3 ms 588 KB n = 4, 21 is a correct answer
4 Incorrect 2 ms 588 KB n = 3, incorrect answer: jury 4 vs contestant 3
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB n = 4, 80 is a correct answer
2 Correct 2 ms 532 KB n = 9, 110 is a correct answer
3 Correct 3 ms 588 KB n = 4, 21 is a correct answer
4 Incorrect 2 ms 588 KB n = 3, incorrect answer: jury 4 vs contestant 3
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB n = 4, 80 is a correct answer
2 Correct 2 ms 532 KB n = 9, 110 is a correct answer
3 Correct 3 ms 588 KB n = 4, 21 is a correct answer
4 Incorrect 2 ms 588 KB n = 3, incorrect answer: jury 4 vs contestant 3