답안 #569219

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
569219 2022-05-27T05:16:08 Z pavement Shortcut (IOI16_shortcut) C++17
0 / 100
1 ms 296 KB
#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define mp make_pair

int n, c;
vector<int> l, d;
vector<ll> P;

ll ans = 1e18;

ll cst(int x, int y) {
	ll ret = 0;
	for (int u = 0; u < n; u++)
		for (int v = 0; v < n; v++)
			ret = max(ret, min({c + max(P[u] - P[x], P[x] - P[u]) + max(P[v] - P[y], P[y] - P[v]), c + max(P[u] - P[y], P[y] - P[u]) + max(P[v] - P[x], P[x] - P[v]), max(P[u] - P[v], P[v] - P[u])}) + d[u] + d[v]);
	return ret;
}

void dnc(int l, int r, int x, int y) {
	if (l > r) return;
	int m = (l + r) >> 1;
	pair<ll, int> opt = mp((ll)1e18, -1);
	for (int i = x; i <= min(m, y); i++)
		opt = min(opt, mp(cst(i, m), i));
	ans = min(ans, opt.first);
	dnc(l, m - 1, x, opt.second);
	dnc(m + 1, r, opt.second, y);
}

ll find_shortcut(int n, vector<int> l, vector<int> d, int c) {
	::n = n;
	::l = l;
	::d = d;
	::c = c;
	P.resize(n);
	for (int i = 1; i < n; i++)
		P[i] = P[i - 1] + l[i - 1];
	dnc(0, n - 1, 0, n - 1);
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB n = 4, 80 is a correct answer
2 Correct 1 ms 296 KB n = 9, 110 is a correct answer
3 Correct 1 ms 212 KB n = 4, 21 is a correct answer
4 Correct 1 ms 212 KB n = 3, 4 is a correct answer
5 Incorrect 1 ms 296 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB n = 4, 80 is a correct answer
2 Correct 1 ms 296 KB n = 9, 110 is a correct answer
3 Correct 1 ms 212 KB n = 4, 21 is a correct answer
4 Correct 1 ms 212 KB n = 3, 4 is a correct answer
5 Incorrect 1 ms 296 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB n = 4, 80 is a correct answer
2 Correct 1 ms 296 KB n = 9, 110 is a correct answer
3 Correct 1 ms 212 KB n = 4, 21 is a correct answer
4 Correct 1 ms 212 KB n = 3, 4 is a correct answer
5 Incorrect 1 ms 296 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB n = 4, 80 is a correct answer
2 Correct 1 ms 296 KB n = 9, 110 is a correct answer
3 Correct 1 ms 212 KB n = 4, 21 is a correct answer
4 Correct 1 ms 212 KB n = 3, 4 is a correct answer
5 Incorrect 1 ms 296 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB n = 4, 80 is a correct answer
2 Correct 1 ms 296 KB n = 9, 110 is a correct answer
3 Correct 1 ms 212 KB n = 4, 21 is a correct answer
4 Correct 1 ms 212 KB n = 3, 4 is a correct answer
5 Incorrect 1 ms 296 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB n = 4, 80 is a correct answer
2 Correct 1 ms 296 KB n = 9, 110 is a correct answer
3 Correct 1 ms 212 KB n = 4, 21 is a correct answer
4 Correct 1 ms 212 KB n = 3, 4 is a correct answer
5 Incorrect 1 ms 296 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB n = 4, 80 is a correct answer
2 Correct 1 ms 296 KB n = 9, 110 is a correct answer
3 Correct 1 ms 212 KB n = 4, 21 is a correct answer
4 Correct 1 ms 212 KB n = 3, 4 is a correct answer
5 Incorrect 1 ms 296 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB n = 4, 80 is a correct answer
2 Correct 1 ms 296 KB n = 9, 110 is a correct answer
3 Correct 1 ms 212 KB n = 4, 21 is a correct answer
4 Correct 1 ms 212 KB n = 3, 4 is a correct answer
5 Incorrect 1 ms 296 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -