답안 #374060

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
374060 2021-03-06T14:03:26 Z KoD Gap (APIO16_gap) C++17
100 / 100
66 ms 3296 KB
#include <vector>
#include <algorithm>
#include "gap.h"

long long findGap(int T, int N) {
	std::vector<long long> vec;
	long long l, r;
	MinMax(0, 1000000000000000000, &l, &r);
	if (T == 1) {
		while (true) {
			vec.push_back(l);
			vec.push_back(r);
			l += 1;
			r -= 1;
			if (l > r || (int) vec.size() >= N) {
				break;
			}
			MinMax(l, r, &l, &r);
			if (l == -1) {
				break;
			}
		}
	}
	else {
		const auto dif = r - l + 1;
		const auto len = (dif + (N - 1) - 1) / (N - 1);
		for (int i = 0; i < N - 1; ++i) {
			long long mn, mx;
			MinMax(l + len * i, l + len * (i + 1) - 1, &mn, &mx);
			if (mn != -1) {
				vec.push_back(mn);
				vec.push_back(mx);
			}
		}
	}
	std::sort(vec.begin(), vec.end());
	long long ans = 0;
	for (int i = 1; i < (int) vec.size(); ++i) {
		ans = std::max(ans, vec[i] - vec[i - 1]);
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 12 ms 876 KB Output is correct
17 Correct 12 ms 876 KB Output is correct
18 Correct 12 ms 876 KB Output is correct
19 Correct 12 ms 876 KB Output is correct
20 Correct 10 ms 896 KB Output is correct
21 Correct 54 ms 2436 KB Output is correct
22 Correct 55 ms 2404 KB Output is correct
23 Correct 48 ms 2276 KB Output is correct
24 Correct 49 ms 2248 KB Output is correct
25 Correct 44 ms 2212 KB Output is correct
26 Correct 49 ms 2352 KB Output is correct
27 Correct 49 ms 2276 KB Output is correct
28 Correct 48 ms 2276 KB Output is correct
29 Correct 48 ms 2276 KB Output is correct
30 Correct 40 ms 2276 KB Output is correct
31 Correct 0 ms 364 KB Output is correct
32 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 16 ms 876 KB Output is correct
17 Correct 16 ms 876 KB Output is correct
18 Correct 15 ms 876 KB Output is correct
19 Correct 15 ms 876 KB Output is correct
20 Correct 8 ms 492 KB Output is correct
21 Correct 64 ms 2404 KB Output is correct
22 Correct 66 ms 2276 KB Output is correct
23 Correct 65 ms 2276 KB Output is correct
24 Correct 64 ms 2220 KB Output is correct
25 Correct 61 ms 3296 KB Output is correct
26 Correct 64 ms 2424 KB Output is correct
27 Correct 63 ms 2276 KB Output is correct
28 Correct 64 ms 2276 KB Output is correct
29 Correct 64 ms 2220 KB Output is correct
30 Correct 34 ms 1516 KB Output is correct
31 Correct 0 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct