Submission #108025

# Submission time Handle Problem Language Result Execution time Memory
108025 2019-04-26T22:59:12 Z luciocf Gap (APIO16_gap) C++14
30 / 100
406 ms 2040 KB
#include <bits/stdc++.h>
#include "gap.h"

using namespace std;

const int maxn = 1e5+10;
const long long maxv = 1e18;

typedef long long ll;

ll a[maxn];

long long findGap(int T, int N)
{
	if (T == 1)
	{
		ll mn, mx;
		MinMax(0, maxv, &mn, &mx);

		int l = 1, r = N;
		a[1] = mn, a[N] = mx;

		while (true)
		{
			if (r-l <= 1) break;

			MinMax(a[l]+1, a[r]-1, &mn, &mx);

			a[++l] = mn, a[--r] = mx;
		}

		ll ans = 0;
		for (int i = 1; i < N; i++)
			ans = max(ans, a[i+1]-a[i]);

		return ans;
	}

	ll s = 0;

	for (int l = 1; l <= N;)
	{
		ll mn, mx;

		for (ll i = 0; i < 60 && s+(1<<i) <= maxv; i++)
		{
			ll t = s+(1<<i);

			MinMax(s, t, &mn, &mx);

			if (mn != -1 && mx != -1) break;
		}

		a[l++] = mn;
		s = a[l-1]+1;
	}

	ll ans = 0;
	for (int i = 1; i < N; i++)
		ans = max(ans, a[i+1]-a[i]);

	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 14 ms 768 KB Output is correct
17 Correct 13 ms 768 KB Output is correct
18 Correct 14 ms 768 KB Output is correct
19 Correct 14 ms 680 KB Output is correct
20 Correct 10 ms 768 KB Output is correct
21 Correct 49 ms 1912 KB Output is correct
22 Correct 50 ms 2040 KB Output is correct
23 Correct 55 ms 1944 KB Output is correct
24 Correct 48 ms 1912 KB Output is correct
25 Correct 46 ms 1912 KB Output is correct
26 Correct 46 ms 1912 KB Output is correct
27 Correct 46 ms 1912 KB Output is correct
28 Correct 50 ms 1912 KB Output is correct
29 Correct 57 ms 1912 KB Output is correct
30 Correct 52 ms 1884 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 256 KB Execution failed because the return code was nonzero
2 Runtime error 2 ms 384 KB Execution failed because the return code was nonzero
3 Runtime error 2 ms 356 KB Execution failed because the return code was nonzero
4 Runtime error 2 ms 384 KB Execution failed because the return code was nonzero
5 Partially correct 2 ms 384 KB Partially correct
6 Runtime error 2 ms 384 KB Execution failed because the return code was nonzero
7 Runtime error 2 ms 380 KB Execution failed because the return code was nonzero
8 Runtime error 2 ms 384 KB Execution failed because the return code was nonzero
9 Runtime error 2 ms 384 KB Execution failed because the return code was nonzero
10 Partially correct 2 ms 384 KB Partially correct
11 Runtime error 2 ms 384 KB Execution failed because the return code was nonzero
12 Runtime error 3 ms 384 KB Execution failed because the return code was nonzero
13 Runtime error 2 ms 384 KB Execution failed because the return code was nonzero
14 Runtime error 2 ms 384 KB Execution failed because the return code was nonzero
15 Partially correct 5 ms 384 KB Partially correct
16 Runtime error 8 ms 512 KB Execution failed because the return code was nonzero
17 Runtime error 13 ms 532 KB Execution failed because the return code was nonzero
18 Runtime error 9 ms 512 KB Execution failed because the return code was nonzero
19 Runtime error 8 ms 512 KB Execution failed because the return code was nonzero
20 Partially correct 14 ms 768 KB Partially correct
21 Runtime error 27 ms 1144 KB Execution failed because the return code was nonzero
22 Runtime error 28 ms 1100 KB Execution failed because the return code was nonzero
23 Runtime error 27 ms 1152 KB Execution failed because the return code was nonzero
24 Runtime error 27 ms 1152 KB Execution failed because the return code was nonzero
25 Partially correct 406 ms 1912 KB Partially correct
26 Runtime error 29 ms 1144 KB Execution failed because the return code was nonzero
27 Runtime error 28 ms 1076 KB Execution failed because the return code was nonzero
28 Runtime error 28 ms 1048 KB Execution failed because the return code was nonzero
29 Runtime error 27 ms 1152 KB Execution failed because the return code was nonzero
30 Partially correct 62 ms 1916 KB Partially correct
31 Runtime error 2 ms 384 KB Execution failed because the return code was nonzero
32 Runtime error 2 ms 384 KB Execution failed because the return code was nonzero