Submission #39806

# Submission time Handle Problem Language Result Execution time Memory
39806 2018-01-19T08:17:35 Z 14kg Gap (APIO16_gap) C++11
30 / 100
107 ms 9052 KB
#include "gap.h"
#include <set>
#define NUM_MAX 1000000000000000000
#define max2(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 + len <= E; s += len) {
		MinMax(s, s + len - 1, &t1, &t2);
		if (t1 < 0) continue;
		res = max2(res, t1 - path), path = t2;
	} 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:20:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (S.size() == n) break;
                ^
# Verdict Execution time Memory 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 1 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 1 ms 4432 KB Output is correct
16 Correct 24 ms 5488 KB Output is correct
17 Correct 19 ms 5488 KB Output is correct
18 Correct 21 ms 5488 KB Output is correct
19 Correct 17 ms 5488 KB Output is correct
20 Correct 13 ms 5488 KB Output is correct
21 Correct 107 ms 9052 KB Output is correct
22 Correct 91 ms 9052 KB Output is correct
23 Correct 84 ms 9052 KB Output is correct
24 Correct 107 ms 9052 KB Output is correct
25 Correct 89 ms 9052 KB Output is correct
26 Correct 95 ms 9052 KB Output is correct
27 Correct 86 ms 9052 KB Output is correct
28 Correct 95 ms 9052 KB Output is correct
29 Correct 80 ms 9052 KB Output is correct
30 Correct 83 ms 9052 KB Output is correct
31 Correct 0 ms 4300 KB Output is correct
32 Correct 0 ms 4300 KB Output is correct
# Verdict Execution time Memory 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 Incorrect 0 ms 4300 KB Output isn't correct
11 Correct 1 ms 4300 KB Output is correct
12 Correct 1 ms 4300 KB Output is correct
13 Correct 2 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 21 ms 4300 KB Output is correct
17 Correct 20 ms 4300 KB Output is correct
18 Correct 21 ms 4300 KB Output is correct
19 Correct 20 ms 4300 KB Output is correct
20 Correct 9 ms 4300 KB Output is correct
21 Correct 77 ms 4300 KB Output is correct
22 Correct 80 ms 4300 KB Output is correct
23 Correct 75 ms 4300 KB Output is correct
24 Correct 73 ms 4300 KB Output is correct
25 Correct 70 ms 4300 KB Output is correct
26 Correct 71 ms 4300 KB Output is correct
27 Correct 76 ms 4300 KB Output is correct
28 Correct 72 ms 4300 KB Output is correct
29 Correct 81 ms 4300 KB Output is correct
30 Correct 38 ms 4300 KB Output is correct
31 Incorrect 0 ms 4300 KB Output isn't correct
32 Correct 0 ms 4300 KB Output is correct