답안 #35166

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
35166 2017-11-18T14:13:21 Z cheater2k Gap (APIO16_gap) C++14
30 / 100
63 ms 5920 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
int n;
long long a[N];

long long solve1() {
	long long s = 0, t = 1e18;
	long long mn, mx;
	for (int i = 1; i <= (n + 1) / 2; ++i) {
		if (s <= t) MinMax(s, t, &mn, &mx);
		a[i] = mn; a[n - i + 1] = mx;
		s = mn + 1, t = mx - 1;
	}
	long long ans = 0;
	for (int i = 2; i <= n; ++i) ans = max(ans, a[i] - a[i - 1]);
	return ans;
}

long long solve2() {
	long long s = 0, t = 1e18;
	long long mn, mx;
	long long gap = (t - s + n - 2) / (n - 1);
	int sz = 0;
	for (long long i = s; i <= t; i += gap + 1) {
		MinMax(i, i + gap, &mn, &mx);
		a[++sz] = mn;
		a[++sz] = mx;
	}
	long long ans = 0;
	for (int i = 2; i <= sz; ++i) ans = max(ans, a[i] - a[i - 1]);
	return ans;
}

long long findGap(int T, int _N) {
	n = _N;
	if (T == 1) return solve1();
	else return solve2();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5920 KB Output is correct
2 Correct 0 ms 5920 KB Output is correct
3 Correct 0 ms 5920 KB Output is correct
4 Correct 0 ms 5920 KB Output is correct
5 Correct 0 ms 5920 KB Output is correct
6 Correct 0 ms 5920 KB Output is correct
7 Correct 0 ms 5920 KB Output is correct
8 Correct 0 ms 5920 KB Output is correct
9 Correct 0 ms 5920 KB Output is correct
10 Correct 0 ms 5920 KB Output is correct
11 Correct 0 ms 5920 KB Output is correct
12 Correct 0 ms 5920 KB Output is correct
13 Correct 0 ms 5920 KB Output is correct
14 Correct 0 ms 5920 KB Output is correct
15 Correct 0 ms 5920 KB Output is correct
16 Correct 16 ms 5920 KB Output is correct
17 Correct 9 ms 5920 KB Output is correct
18 Correct 13 ms 5920 KB Output is correct
19 Correct 16 ms 5920 KB Output is correct
20 Correct 9 ms 5920 KB Output is correct
21 Correct 56 ms 5920 KB Output is correct
22 Correct 56 ms 5920 KB Output is correct
23 Correct 49 ms 5920 KB Output is correct
24 Correct 59 ms 5920 KB Output is correct
25 Correct 53 ms 5920 KB Output is correct
26 Correct 53 ms 5920 KB Output is correct
27 Correct 63 ms 5920 KB Output is correct
28 Correct 56 ms 5920 KB Output is correct
29 Correct 46 ms 5920 KB Output is correct
30 Correct 43 ms 5920 KB Output is correct
31 Correct 0 ms 5920 KB Output is correct
32 Correct 0 ms 5920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5920 KB Output is correct
2 Incorrect 0 ms 5920 KB Output isn't correct
3 Incorrect 0 ms 5920 KB Output isn't correct
4 Incorrect 0 ms 5920 KB Output isn't correct
5 Incorrect 0 ms 5920 KB Output isn't correct
6 Incorrect 0 ms 5920 KB Output isn't correct
7 Incorrect 0 ms 5920 KB Output isn't correct
8 Incorrect 0 ms 5920 KB Output isn't correct
9 Incorrect 0 ms 5920 KB Output isn't correct
10 Incorrect 0 ms 5920 KB Output isn't correct
11 Incorrect 0 ms 5920 KB Output isn't correct
12 Incorrect 0 ms 5920 KB Output isn't correct
13 Incorrect 0 ms 5920 KB Output isn't correct
14 Incorrect 0 ms 5920 KB Output isn't correct
15 Incorrect 0 ms 5920 KB Output isn't correct
16 Incorrect 19 ms 5920 KB Output isn't correct
17 Incorrect 19 ms 5920 KB Output isn't correct
18 Incorrect 16 ms 5920 KB Output isn't correct
19 Incorrect 19 ms 5920 KB Output isn't correct
20 Incorrect 6 ms 5920 KB Output isn't correct
21 Incorrect 46 ms 5920 KB Expected int32, but "500036270788308130" found
22 Incorrect 43 ms 5920 KB Expected int32, but "500037286518929092" found
23 Runtime error 49 ms 5920 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Incorrect 53 ms 5920 KB Expected int32, but "500042983460151473" found
25 Incorrect 26 ms 5920 KB Output isn't correct
26 Runtime error 53 ms 5920 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Incorrect 59 ms 5920 KB Output isn't correct
28 Runtime error 53 ms 5920 KB Execution killed with signal 11 (could be triggered by violating memory limits)
29 Runtime error 49 ms 5920 KB Execution killed with signal 11 (could be triggered by violating memory limits)
30 Incorrect 23 ms 5920 KB Output isn't correct
31 Incorrect 0 ms 5920 KB Output isn't correct
32 Incorrect 0 ms 5920 KB Output isn't correct