답안 #56036

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
56036 2018-07-09T13:05:24 Z KieranHorgan Shortcut (IOI16_shortcut) C++17
0 / 100
2 ms 548 KB
#include "shortcut.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long

ll prefix[3005];
ll bestB[3005];
ll bestA[3005];

long long find_shortcut(int n, vector<int> l, vector<int> d, int c) {
	vector<int> L = {0,0};
	for(auto i: l) L.push_back(i);
	l=L;
	vector<int> D = {0};
	for(auto i: d) D.push_back(i);
	d=D;

	for(int i = 1; i <= n; i++)
		prefix[i] = prefix[i-1] + l[i];

	ll diam = 1ll<<50;

	vector<int> Db = D;
	for(int i = 1; i <= n; i++)
		Db[i] = max(Db[i], Db[i-1]+l[i]);
	vector<int> Da = D;
	for(int i = n-1; i >= 1; i--)
		Da[i] = max(Da[i], Da[i+1]+l[i+1]);

	// cerr << "  ";
	// for(int i = 2; i <= n; i++)
		// cerr << l[i] << "  ";
	// cerr << endl;
	// for(int i = 1; i <= n; i++) {
		// cerr << d[i] << "  ";
		// if(d[i]==0)
			// cerr << " ";
	// }
	// cerr << endl;
	// cerr << endl;
// 
	// for(int i = 1; i <= n; i++)
		// cerr << Db[i] << "  ";
	// cerr << endl;
	// cerr << endl;
	// for(int i = 1; i <= n; i++)
		// cerr << Da[i] << "  ";
	// cerr << endl;
	// cerr << endl;

	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			bestB[j] = max(bestB[j], prefix[j]-prefix[i] + d[i] + d[j]),
			bestA[i] = max(bestA[i], prefix[j]-prefix[i] + d[i] + d[j]);

	// for(int i = 1; i <= n; i++)
		// cerr << bestB[i] << "  ";
	// cerr << endl;
	// for(int i = 1; i <= n; i++)
		// cerr << bestA[i] << "  ";
	// cerr << endl;
	// cerr << endl;

	for(ll ci = 1; ci <= n; ci++) {
		for(ll cj = ci+1; cj <= n; cj++) {
			d[ci] = Db[ci];
			d[cj] = Da[cj];

			ll currDiam = max(bestB[ci], bestA[cj]);
			for(ll i = ci; i <= cj; i++){
				for(ll j = i+1; j <= cj; j++) {
					currDiam = max(currDiam, min(prefix[j]-prefix[i] + d[i] + d[j], prefix[cj]-prefix[j] + c + prefix[i]-prefix[ci] + d[i] + d[j]));
				}
			}
 			diam = min(diam, currDiam);

			d[ci] = D[ci];
			d[cj] = D[cj];
		}
	}

    return diam;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB n = 4, 80 is a correct answer
2 Correct 2 ms 360 KB n = 9, 110 is a correct answer
3 Correct 2 ms 528 KB n = 4, 21 is a correct answer
4 Correct 2 ms 548 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 548 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB n = 4, 80 is a correct answer
2 Correct 2 ms 360 KB n = 9, 110 is a correct answer
3 Correct 2 ms 528 KB n = 4, 21 is a correct answer
4 Correct 2 ms 548 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 548 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB n = 4, 80 is a correct answer
2 Correct 2 ms 360 KB n = 9, 110 is a correct answer
3 Correct 2 ms 528 KB n = 4, 21 is a correct answer
4 Correct 2 ms 548 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 548 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB n = 4, 80 is a correct answer
2 Correct 2 ms 360 KB n = 9, 110 is a correct answer
3 Correct 2 ms 528 KB n = 4, 21 is a correct answer
4 Correct 2 ms 548 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 548 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB n = 4, 80 is a correct answer
2 Correct 2 ms 360 KB n = 9, 110 is a correct answer
3 Correct 2 ms 528 KB n = 4, 21 is a correct answer
4 Correct 2 ms 548 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 548 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB n = 4, 80 is a correct answer
2 Correct 2 ms 360 KB n = 9, 110 is a correct answer
3 Correct 2 ms 528 KB n = 4, 21 is a correct answer
4 Correct 2 ms 548 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 548 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB n = 4, 80 is a correct answer
2 Correct 2 ms 360 KB n = 9, 110 is a correct answer
3 Correct 2 ms 528 KB n = 4, 21 is a correct answer
4 Correct 2 ms 548 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 548 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB n = 4, 80 is a correct answer
2 Correct 2 ms 360 KB n = 9, 110 is a correct answer
3 Correct 2 ms 528 KB n = 4, 21 is a correct answer
4 Correct 2 ms 548 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 548 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -