답안 #921883

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921883 2024-02-04T12:46:48 Z lamter Gap (APIO16_gap) C++17
100 / 100
53 ms 9264 KB
#include "gap.h"
#include <bits/stdc++.h>

const long long iii = 1E18;

inline long long ceil(long long int a, long long int b) {
	return a / b + (a % b != 0);
}

void MyMinMax(long long x, long long y, long long& min, long long& max) {
	long long* min_place_holder = new long long;
	long long* max_place_holder = new long long;

	MinMax(x, y, min_place_holder, max_place_holder);

	min = *min_place_holder;
	max = *max_place_holder;
}

long long findGap(int T, int n) {
	if (T == 1) {
		std::vector <long long> a(n);
		MyMinMax(0, iii, a[0], a[n - 1]);
		for (int l = 1, r = n - 2; l <= r; l += 1, r -= 1) {
			MyMinMax(a[l - 1] + 1, a[r + 1] - 1, a[l], a[r]);
		}
		long long int ans = 0;
		for (int i = 0; i + 1 < n; i += 1)
			ans = std::max(ans, a[i + 1] - a[i]);
		return ans;
	}

	if (T == 2) {
		long long min, max;
		MyMinMax(0, iii, min, max);
		long long siz = ceil(max - min, n - 1);
		long long xaxa = -1;
		long long bong = siz;

		while (min <= max) {
			long long yeunhau, coiaochonhau;
			MyMinMax(min, min + siz, yeunhau, coiaochonhau);

			if (yeunhau != -1) {
				if (xaxa != -1) {
					bong = std::max(bong, yeunhau - xaxa);
				}
				xaxa = coiaochonhau;
			}

			min += siz + 1;
		}
		return bong;
	}

	assert(0);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 2 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 8 ms 3352 KB Output is correct
17 Correct 9 ms 3348 KB Output is correct
18 Correct 8 ms 3360 KB Output is correct
19 Correct 9 ms 3352 KB Output is correct
20 Correct 6 ms 3344 KB Output is correct
21 Correct 32 ms 6744 KB Output is correct
22 Correct 29 ms 6684 KB Output is correct
23 Correct 29 ms 6700 KB Output is correct
24 Correct 29 ms 6948 KB Output is correct
25 Correct 27 ms 6996 KB Output is correct
26 Correct 32 ms 6688 KB Output is correct
27 Correct 30 ms 6688 KB Output is correct
28 Correct 31 ms 6688 KB Output is correct
29 Correct 29 ms 6616 KB Output is correct
30 Correct 25 ms 6752 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 10 ms 4288 KB Output is correct
17 Correct 11 ms 4288 KB Output is correct
18 Correct 11 ms 4120 KB Output is correct
19 Correct 11 ms 4344 KB Output is correct
20 Correct 6 ms 4092 KB Output is correct
21 Correct 42 ms 8868 KB Output is correct
22 Correct 42 ms 8996 KB Output is correct
23 Correct 53 ms 8944 KB Output is correct
24 Correct 43 ms 8992 KB Output is correct
25 Correct 42 ms 8964 KB Output is correct
26 Correct 43 ms 9264 KB Output is correct
27 Correct 48 ms 8960 KB Output is correct
28 Correct 43 ms 8984 KB Output is correct
29 Correct 47 ms 9060 KB Output is correct
30 Correct 25 ms 8420 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct