답안 #39808

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
39808 2018-01-19T08:22:48 Z 14kg Gap (APIO16_gap) C++11
100 / 100
103 ms 9052 KB
#include "gap.h"
#include <set>
#define NUM_MAX 1000000000000000000
#define max2(x,y) (x>y?x:y)
#define min2(x,y) (x<y?x:y)

using namespace std;
int n;
set<long long> S;

long long f1() {
	long long l = 0, r = NUM_MAX;
	long long t1, t2, res = 0;

	while (l <= r) {
		MinMax(l, r, &t1, &t2);
		if (t1 < 0) break;
		
		S.insert(l = t1), S.insert(r = t2);
		l++, r--;
		if (S.size() == n) break;
	}
	
	t1 = NUM_MAX;
	for (auto i : S) res = max2(res, i - t1), t1 = i;
	return res;
}
long long f2() {
	long long S, E, len, res, t1, t2, path = NUM_MAX;

	MinMax(0, NUM_MAX, &S, &E);
	res = len = (E - S) / (n - 1) + ((E - S) % (n - 1) ? 1 : 0);

	for (long long s = S; s < E; s += len) {
		MinMax(s, min2(s + len - 1, E - 1), &t1, &t2);
		if (t1 < 0) continue;
		res = max2(res, t1 - path), path = t2;
	} res = max2(res, E - path);
	return res;
}
long long findGap(int T, int _n) {
	n = _n;
	if (T == 1) return f1();
	else return f2();
}

Compilation message

gap.cpp: In function 'long long int f1()':
gap.cpp:21:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (S.size() == n) break;
                ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4300 KB Output is correct
2 Correct 0 ms 4300 KB Output is correct
3 Correct 0 ms 4300 KB Output is correct
4 Correct 0 ms 4300 KB Output is correct
5 Correct 0 ms 4300 KB Output is correct
6 Correct 0 ms 4300 KB Output is correct
7 Correct 0 ms 4300 KB Output is correct
8 Correct 0 ms 4300 KB Output is correct
9 Correct 0 ms 4300 KB Output is correct
10 Correct 0 ms 4300 KB Output is correct
11 Correct 1 ms 4432 KB Output is correct
12 Correct 2 ms 4432 KB Output is correct
13 Correct 1 ms 4432 KB Output is correct
14 Correct 1 ms 4432 KB Output is correct
15 Correct 0 ms 4432 KB Output is correct
16 Correct 20 ms 5488 KB Output is correct
17 Correct 24 ms 5488 KB Output is correct
18 Correct 20 ms 5488 KB Output is correct
19 Correct 25 ms 5488 KB Output is correct
20 Correct 15 ms 5488 KB Output is correct
21 Correct 103 ms 9052 KB Output is correct
22 Correct 89 ms 9052 KB Output is correct
23 Correct 84 ms 9052 KB Output is correct
24 Correct 77 ms 9052 KB Output is correct
25 Correct 67 ms 9052 KB Output is correct
26 Correct 86 ms 9052 KB Output is correct
27 Correct 77 ms 9052 KB Output is correct
28 Correct 80 ms 9052 KB Output is correct
29 Correct 87 ms 9052 KB Output is correct
30 Correct 57 ms 9052 KB Output is correct
31 Correct 0 ms 4300 KB Output is correct
32 Correct 0 ms 4300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4300 KB Output is correct
2 Correct 0 ms 4300 KB Output is correct
3 Correct 0 ms 4300 KB Output is correct
4 Correct 0 ms 4300 KB Output is correct
5 Correct 0 ms 4300 KB Output is correct
6 Correct 0 ms 4300 KB Output is correct
7 Correct 0 ms 4300 KB Output is correct
8 Correct 0 ms 4300 KB Output is correct
9 Correct 0 ms 4300 KB Output is correct
10 Correct 0 ms 4300 KB Output is correct
11 Correct 1 ms 4300 KB Output is correct
12 Correct 1 ms 4300 KB Output is correct
13 Correct 0 ms 4300 KB Output is correct
14 Correct 1 ms 4300 KB Output is correct
15 Correct 1 ms 4300 KB Output is correct
16 Correct 19 ms 4300 KB Output is correct
17 Correct 20 ms 4300 KB Output is correct
18 Correct 16 ms 4300 KB Output is correct
19 Correct 15 ms 4300 KB Output is correct
20 Correct 9 ms 4300 KB Output is correct
21 Correct 74 ms 4300 KB Output is correct
22 Correct 77 ms 4300 KB Output is correct
23 Correct 67 ms 4300 KB Output is correct
24 Correct 71 ms 4300 KB Output is correct
25 Correct 66 ms 4300 KB Output is correct
26 Correct 75 ms 4300 KB Output is correct
27 Correct 65 ms 4300 KB Output is correct
28 Correct 67 ms 4300 KB Output is correct
29 Correct 72 ms 4300 KB Output is correct
30 Correct 41 ms 4300 KB Output is correct
31 Correct 0 ms 4300 KB Output is correct
32 Correct 0 ms 4300 KB Output is correct