답안 #56039

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
56039 2018-07-09T13:08:34 Z KieranHorgan Shortcut (IOI16_shortcut) C++17
0 / 100
4 ms 768 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 = i+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 484 KB n = 9, 110 is a correct answer
3 Correct 2 ms 484 KB n = 4, 21 is a correct answer
4 Correct 2 ms 484 KB n = 3, 4 is a correct answer
5 Correct 2 ms 484 KB n = 2, 62 is a correct answer
6 Correct 3 ms 520 KB n = 2, 3 is a correct answer
7 Correct 3 ms 520 KB n = 3, 29 is a correct answer
8 Correct 2 ms 584 KB n = 2, 3 is a correct answer
9 Correct 2 ms 588 KB n = 2, 3 is a correct answer
10 Correct 2 ms 592 KB n = 2, 2000000001 is a correct answer
11 Correct 4 ms 596 KB n = 2, 3000000000 is a correct answer
12 Correct 2 ms 596 KB n = 3, 3000000000 is a correct answer
13 Correct 2 ms 712 KB n = 3, 3000000000 is a correct answer
14 Correct 3 ms 712 KB n = 4, 3000000001 is a correct answer
15 Correct 3 ms 720 KB n = 4, 4000000000 is a correct answer
16 Correct 3 ms 720 KB n = 5, 4000000000 is a correct answer
17 Correct 3 ms 728 KB n = 10, 1000000343 is a correct answer
18 Correct 2 ms 764 KB n = 10, 3189 is a correct answer
19 Incorrect 3 ms 768 KB n = 10, incorrect answer: jury 7000000000 vs contestant 5000000000
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB n = 4, 80 is a correct answer
2 Correct 2 ms 484 KB n = 9, 110 is a correct answer
3 Correct 2 ms 484 KB n = 4, 21 is a correct answer
4 Correct 2 ms 484 KB n = 3, 4 is a correct answer
5 Correct 2 ms 484 KB n = 2, 62 is a correct answer
6 Correct 3 ms 520 KB n = 2, 3 is a correct answer
7 Correct 3 ms 520 KB n = 3, 29 is a correct answer
8 Correct 2 ms 584 KB n = 2, 3 is a correct answer
9 Correct 2 ms 588 KB n = 2, 3 is a correct answer
10 Correct 2 ms 592 KB n = 2, 2000000001 is a correct answer
11 Correct 4 ms 596 KB n = 2, 3000000000 is a correct answer
12 Correct 2 ms 596 KB n = 3, 3000000000 is a correct answer
13 Correct 2 ms 712 KB n = 3, 3000000000 is a correct answer
14 Correct 3 ms 712 KB n = 4, 3000000001 is a correct answer
15 Correct 3 ms 720 KB n = 4, 4000000000 is a correct answer
16 Correct 3 ms 720 KB n = 5, 4000000000 is a correct answer
17 Correct 3 ms 728 KB n = 10, 1000000343 is a correct answer
18 Correct 2 ms 764 KB n = 10, 3189 is a correct answer
19 Incorrect 3 ms 768 KB n = 10, incorrect answer: jury 7000000000 vs contestant 5000000000
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB n = 4, 80 is a correct answer
2 Correct 2 ms 484 KB n = 9, 110 is a correct answer
3 Correct 2 ms 484 KB n = 4, 21 is a correct answer
4 Correct 2 ms 484 KB n = 3, 4 is a correct answer
5 Correct 2 ms 484 KB n = 2, 62 is a correct answer
6 Correct 3 ms 520 KB n = 2, 3 is a correct answer
7 Correct 3 ms 520 KB n = 3, 29 is a correct answer
8 Correct 2 ms 584 KB n = 2, 3 is a correct answer
9 Correct 2 ms 588 KB n = 2, 3 is a correct answer
10 Correct 2 ms 592 KB n = 2, 2000000001 is a correct answer
11 Correct 4 ms 596 KB n = 2, 3000000000 is a correct answer
12 Correct 2 ms 596 KB n = 3, 3000000000 is a correct answer
13 Correct 2 ms 712 KB n = 3, 3000000000 is a correct answer
14 Correct 3 ms 712 KB n = 4, 3000000001 is a correct answer
15 Correct 3 ms 720 KB n = 4, 4000000000 is a correct answer
16 Correct 3 ms 720 KB n = 5, 4000000000 is a correct answer
17 Correct 3 ms 728 KB n = 10, 1000000343 is a correct answer
18 Correct 2 ms 764 KB n = 10, 3189 is a correct answer
19 Incorrect 3 ms 768 KB n = 10, incorrect answer: jury 7000000000 vs contestant 5000000000
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB n = 4, 80 is a correct answer
2 Correct 2 ms 484 KB n = 9, 110 is a correct answer
3 Correct 2 ms 484 KB n = 4, 21 is a correct answer
4 Correct 2 ms 484 KB n = 3, 4 is a correct answer
5 Correct 2 ms 484 KB n = 2, 62 is a correct answer
6 Correct 3 ms 520 KB n = 2, 3 is a correct answer
7 Correct 3 ms 520 KB n = 3, 29 is a correct answer
8 Correct 2 ms 584 KB n = 2, 3 is a correct answer
9 Correct 2 ms 588 KB n = 2, 3 is a correct answer
10 Correct 2 ms 592 KB n = 2, 2000000001 is a correct answer
11 Correct 4 ms 596 KB n = 2, 3000000000 is a correct answer
12 Correct 2 ms 596 KB n = 3, 3000000000 is a correct answer
13 Correct 2 ms 712 KB n = 3, 3000000000 is a correct answer
14 Correct 3 ms 712 KB n = 4, 3000000001 is a correct answer
15 Correct 3 ms 720 KB n = 4, 4000000000 is a correct answer
16 Correct 3 ms 720 KB n = 5, 4000000000 is a correct answer
17 Correct 3 ms 728 KB n = 10, 1000000343 is a correct answer
18 Correct 2 ms 764 KB n = 10, 3189 is a correct answer
19 Incorrect 3 ms 768 KB n = 10, incorrect answer: jury 7000000000 vs contestant 5000000000
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB n = 4, 80 is a correct answer
2 Correct 2 ms 484 KB n = 9, 110 is a correct answer
3 Correct 2 ms 484 KB n = 4, 21 is a correct answer
4 Correct 2 ms 484 KB n = 3, 4 is a correct answer
5 Correct 2 ms 484 KB n = 2, 62 is a correct answer
6 Correct 3 ms 520 KB n = 2, 3 is a correct answer
7 Correct 3 ms 520 KB n = 3, 29 is a correct answer
8 Correct 2 ms 584 KB n = 2, 3 is a correct answer
9 Correct 2 ms 588 KB n = 2, 3 is a correct answer
10 Correct 2 ms 592 KB n = 2, 2000000001 is a correct answer
11 Correct 4 ms 596 KB n = 2, 3000000000 is a correct answer
12 Correct 2 ms 596 KB n = 3, 3000000000 is a correct answer
13 Correct 2 ms 712 KB n = 3, 3000000000 is a correct answer
14 Correct 3 ms 712 KB n = 4, 3000000001 is a correct answer
15 Correct 3 ms 720 KB n = 4, 4000000000 is a correct answer
16 Correct 3 ms 720 KB n = 5, 4000000000 is a correct answer
17 Correct 3 ms 728 KB n = 10, 1000000343 is a correct answer
18 Correct 2 ms 764 KB n = 10, 3189 is a correct answer
19 Incorrect 3 ms 768 KB n = 10, incorrect answer: jury 7000000000 vs contestant 5000000000
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB n = 4, 80 is a correct answer
2 Correct 2 ms 484 KB n = 9, 110 is a correct answer
3 Correct 2 ms 484 KB n = 4, 21 is a correct answer
4 Correct 2 ms 484 KB n = 3, 4 is a correct answer
5 Correct 2 ms 484 KB n = 2, 62 is a correct answer
6 Correct 3 ms 520 KB n = 2, 3 is a correct answer
7 Correct 3 ms 520 KB n = 3, 29 is a correct answer
8 Correct 2 ms 584 KB n = 2, 3 is a correct answer
9 Correct 2 ms 588 KB n = 2, 3 is a correct answer
10 Correct 2 ms 592 KB n = 2, 2000000001 is a correct answer
11 Correct 4 ms 596 KB n = 2, 3000000000 is a correct answer
12 Correct 2 ms 596 KB n = 3, 3000000000 is a correct answer
13 Correct 2 ms 712 KB n = 3, 3000000000 is a correct answer
14 Correct 3 ms 712 KB n = 4, 3000000001 is a correct answer
15 Correct 3 ms 720 KB n = 4, 4000000000 is a correct answer
16 Correct 3 ms 720 KB n = 5, 4000000000 is a correct answer
17 Correct 3 ms 728 KB n = 10, 1000000343 is a correct answer
18 Correct 2 ms 764 KB n = 10, 3189 is a correct answer
19 Incorrect 3 ms 768 KB n = 10, incorrect answer: jury 7000000000 vs contestant 5000000000
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB n = 4, 80 is a correct answer
2 Correct 2 ms 484 KB n = 9, 110 is a correct answer
3 Correct 2 ms 484 KB n = 4, 21 is a correct answer
4 Correct 2 ms 484 KB n = 3, 4 is a correct answer
5 Correct 2 ms 484 KB n = 2, 62 is a correct answer
6 Correct 3 ms 520 KB n = 2, 3 is a correct answer
7 Correct 3 ms 520 KB n = 3, 29 is a correct answer
8 Correct 2 ms 584 KB n = 2, 3 is a correct answer
9 Correct 2 ms 588 KB n = 2, 3 is a correct answer
10 Correct 2 ms 592 KB n = 2, 2000000001 is a correct answer
11 Correct 4 ms 596 KB n = 2, 3000000000 is a correct answer
12 Correct 2 ms 596 KB n = 3, 3000000000 is a correct answer
13 Correct 2 ms 712 KB n = 3, 3000000000 is a correct answer
14 Correct 3 ms 712 KB n = 4, 3000000001 is a correct answer
15 Correct 3 ms 720 KB n = 4, 4000000000 is a correct answer
16 Correct 3 ms 720 KB n = 5, 4000000000 is a correct answer
17 Correct 3 ms 728 KB n = 10, 1000000343 is a correct answer
18 Correct 2 ms 764 KB n = 10, 3189 is a correct answer
19 Incorrect 3 ms 768 KB n = 10, incorrect answer: jury 7000000000 vs contestant 5000000000
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB n = 4, 80 is a correct answer
2 Correct 2 ms 484 KB n = 9, 110 is a correct answer
3 Correct 2 ms 484 KB n = 4, 21 is a correct answer
4 Correct 2 ms 484 KB n = 3, 4 is a correct answer
5 Correct 2 ms 484 KB n = 2, 62 is a correct answer
6 Correct 3 ms 520 KB n = 2, 3 is a correct answer
7 Correct 3 ms 520 KB n = 3, 29 is a correct answer
8 Correct 2 ms 584 KB n = 2, 3 is a correct answer
9 Correct 2 ms 588 KB n = 2, 3 is a correct answer
10 Correct 2 ms 592 KB n = 2, 2000000001 is a correct answer
11 Correct 4 ms 596 KB n = 2, 3000000000 is a correct answer
12 Correct 2 ms 596 KB n = 3, 3000000000 is a correct answer
13 Correct 2 ms 712 KB n = 3, 3000000000 is a correct answer
14 Correct 3 ms 712 KB n = 4, 3000000001 is a correct answer
15 Correct 3 ms 720 KB n = 4, 4000000000 is a correct answer
16 Correct 3 ms 720 KB n = 5, 4000000000 is a correct answer
17 Correct 3 ms 728 KB n = 10, 1000000343 is a correct answer
18 Correct 2 ms 764 KB n = 10, 3189 is a correct answer
19 Incorrect 3 ms 768 KB n = 10, incorrect answer: jury 7000000000 vs contestant 5000000000
20 Halted 0 ms 0 KB -