Submission #108026

# Submission time Handle Problem Language Result Execution time Memory
108026 2019-04-26T23:12:46 Z luciocf Gap (APIO16_gap) C++14
38.8102 / 100
877 ms 2156 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; l++)
	{
		ll mn = -1, mx = -1;

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

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

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

		if (mn == -1)
			MinMax(s, maxv, &mn, &mx);

		a[l] = mn; s = a[l]+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 384 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 512 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 428 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 3 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 19 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 18 ms 768 KB Output is correct
20 Correct 10 ms 768 KB Output is correct
21 Correct 49 ms 1912 KB Output is correct
22 Correct 54 ms 1884 KB Output is correct
23 Correct 49 ms 2040 KB Output is correct
24 Correct 51 ms 1912 KB Output is correct
25 Correct 52 ms 1868 KB Output is correct
26 Correct 48 ms 1912 KB Output is correct
27 Correct 64 ms 1912 KB Output is correct
28 Correct 51 ms 2040 KB Output is correct
29 Correct 53 ms 1884 KB Output is correct
30 Correct 36 ms 1912 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 256 KB Partially correct
2 Partially correct 2 ms 384 KB Partially correct
3 Partially correct 3 ms 384 KB Partially correct
4 Partially correct 2 ms 384 KB Partially correct
5 Partially correct 4 ms 384 KB Partially correct
6 Partially correct 3 ms 384 KB Partially correct
7 Partially correct 2 ms 384 KB Partially correct
8 Partially correct 3 ms 384 KB Partially correct
9 Partially correct 3 ms 384 KB Partially correct
10 Partially correct 2 ms 384 KB Partially correct
11 Partially correct 10 ms 384 KB Partially correct
12 Partially correct 10 ms 384 KB Partially correct
13 Partially correct 10 ms 384 KB Partially correct
14 Partially correct 9 ms 384 KB Partially correct
15 Partially correct 6 ms 384 KB Partially correct
16 Partially correct 188 ms 672 KB Partially correct
17 Partially correct 189 ms 760 KB Partially correct
18 Partially correct 180 ms 760 KB Partially correct
19 Partially correct 265 ms 760 KB Partially correct
20 Partially correct 20 ms 768 KB Partially correct
21 Partially correct 734 ms 1916 KB Partially correct
22 Partially correct 739 ms 2052 KB Partially correct
23 Partially correct 721 ms 2012 KB Partially correct
24 Partially correct 816 ms 2156 KB Partially correct
25 Partially correct 394 ms 1936 KB Partially correct
26 Partially correct 877 ms 2040 KB Partially correct
27 Partially correct 839 ms 1892 KB Partially correct
28 Partially correct 831 ms 1912 KB Partially correct
29 Partially correct 804 ms 1884 KB Partially correct
30 Partially correct 59 ms 1912 KB Partially correct
31 Partially correct 2 ms 384 KB Partially correct
32 Partially correct 3 ms 384 KB Partially correct