답안 #1076892

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1076892 2024-08-26T18:05:10 Z TFF Gap (APIO16_gap) C++17
89.5342 / 100
46 ms 3276 KB
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
const long long MX = 1000000000000000000;
long long mn, mx;
int n;
long long findGap(int t, int N) {
	n = N;
    if (t == 1) {
		long long left, right;
		left = 0;
		right = MX;
		vector<long long> arr1, arr2;
		for (int i = 0; i < (n + 1) / 2; i++) {
			MinMax(left, right, &mn, &mx);
			arr1.push_back(mn);
			arr2.push_back(mx);
			left = mn + 1;
			right = mx - 1;
		}
		long long ans = arr2.back() - arr1.back();
		for (int i = 0; i < (int)arr1.size() - 1; i++) {
			ans = max(ans, arr1[i + 1] - arr1[i]);
			ans = max(ans, arr2[i] - arr2[i + 1]);
		}
		return ans;
	}
	MinMax(0, MX, &mn, &mx);
	long long left = mn;
	long long right = mx;
	long long delta = (mx - mn + n - 2) / (n - 1);
	vector<long long> pos;
	pos.push_back(left);
	for (int i = 0; i < n - 1; i++) {
		MinMax(min(left + i * delta + 1, right), min(left + (i + 1) * delta, right), &mn, &mx);
		if (mn != -1) {
			pos.push_back(mn);
			pos.push_back(mx);
		}
	}
	pos.push_back(right);
	long long ans = 0;
	for (int i = 0; i < (int)pos.size(); i++) {
		ans = max(ans, pos[i + 1] - pos[i]);
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 452 KB Output is correct
15 Correct 1 ms 452 KB Output is correct
16 Correct 7 ms 856 KB Output is correct
17 Correct 7 ms 856 KB Output is correct
18 Correct 7 ms 856 KB Output is correct
19 Correct 6 ms 856 KB Output is correct
20 Correct 6 ms 852 KB Output is correct
21 Correct 28 ms 1924 KB Output is correct
22 Correct 33 ms 2256 KB Output is correct
23 Correct 38 ms 1916 KB Output is correct
24 Correct 36 ms 1916 KB Output is correct
25 Correct 25 ms 1924 KB Output is correct
26 Correct 29 ms 1980 KB Output is correct
27 Correct 27 ms 1924 KB Output is correct
28 Correct 27 ms 1924 KB Output is correct
29 Correct 30 ms 1916 KB Output is correct
30 Correct 22 ms 1956 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 452 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 9 ms 980 KB Output is correct
17 Correct 9 ms 980 KB Output is correct
18 Correct 11 ms 980 KB Output is correct
19 Correct 10 ms 980 KB Output is correct
20 Partially correct 7 ms 600 KB Partially correct
21 Correct 36 ms 2256 KB Output is correct
22 Correct 45 ms 2248 KB Output is correct
23 Correct 36 ms 2324 KB Output is correct
24 Correct 36 ms 2192 KB Output is correct
25 Correct 34 ms 3276 KB Output is correct
26 Correct 36 ms 2256 KB Output is correct
27 Correct 36 ms 2248 KB Output is correct
28 Correct 46 ms 2160 KB Output is correct
29 Correct 38 ms 2188 KB Output is correct
30 Partially correct 22 ms 1624 KB Partially correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct