Submission #24969

# Submission time Handle Problem Language Result Execution time Memory
24969 2017-06-19T12:39:36 Z gabrielsimoes Gap (APIO16_gap) C++14
30 / 100
59 ms 4900 KB
#include "gap.h"
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long ll;
const ll MIN = 0, MAX = 1000000000000000000;

void MM(ll a, ll b, ll *c, ll *d) {
	// printf("MinMax of %lld %lld\n", a, b);
	MinMax(a, b, c, d);
}

ll solve1(int n) {
	ll v[n+1];
	int i = 1, k = n;
	ll mn = MIN, mx = MAX;
	while (i <= k) {
		MinMax(mn, mx, v+i, v+k);
		mn = v[i++]+1;
		mx = v[k--]-1;
	}

	ll ret = 1;
	for (int i = 1; i < n; i++)
		ret = max(ret, v[i+1] - v[i]);
	return ret;
}

ll solve2(int n) {
	ll cur, lim;
	MM(MIN, MAX, &cur, &lim);
	ll ans = 1, test, l, r;
	while (cur < lim) {
		// printf("cur %lld ans %lld\n", cur, ans);
		test = ans + 1;
		do {
			// printf("test %lld\n", test);
			MM(cur+test, cur+test*2, &l, &r);
			test = test*2;
		} while (l == -1);
		ans = max(ans, l - cur);
		cur = r;
	}
	return ans;
}

ll findGap(int t, int n)
{
	return (t == 1 || n <= 8) ? solve1(n) : solve2(n);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4240 KB Output is correct
2 Correct 0 ms 4240 KB Output is correct
3 Correct 0 ms 4240 KB Output is correct
4 Correct 0 ms 4240 KB Output is correct
5 Correct 0 ms 4240 KB Output is correct
6 Correct 0 ms 4240 KB Output is correct
7 Correct 0 ms 4240 KB Output is correct
8 Correct 0 ms 4240 KB Output is correct
9 Correct 0 ms 4240 KB Output is correct
10 Correct 0 ms 4240 KB Output is correct
11 Correct 0 ms 4240 KB Output is correct
12 Correct 0 ms 4240 KB Output is correct
13 Correct 0 ms 4240 KB Output is correct
14 Correct 0 ms 4240 KB Output is correct
15 Correct 0 ms 4240 KB Output is correct
16 Correct 16 ms 4312 KB Output is correct
17 Correct 13 ms 4308 KB Output is correct
18 Correct 13 ms 4312 KB Output is correct
19 Correct 13 ms 4312 KB Output is correct
20 Correct 9 ms 4312 KB Output is correct
21 Correct 46 ms 4900 KB Output is correct
22 Correct 49 ms 4892 KB Output is correct
23 Correct 49 ms 4892 KB Output is correct
24 Correct 56 ms 4896 KB Output is correct
25 Correct 49 ms 4896 KB Output is correct
26 Correct 53 ms 4896 KB Output is correct
27 Correct 59 ms 4896 KB Output is correct
28 Correct 49 ms 4900 KB Output is correct
29 Correct 49 ms 4896 KB Output is correct
30 Correct 39 ms 4900 KB Output is correct
31 Correct 0 ms 4240 KB Output is correct
32 Correct 0 ms 4240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4240 KB Output is correct
2 Incorrect 0 ms 4240 KB Output isn't correct
3 Incorrect 0 ms 4240 KB Output isn't correct
4 Partially correct 0 ms 4240 KB Partially correct
5 Incorrect 0 ms 4240 KB Unexpected end of file - int64 expected
6 Incorrect 0 ms 4240 KB Unexpected end of file - int64 expected
7 Incorrect 0 ms 4240 KB Unexpected end of file - int64 expected
8 Incorrect 0 ms 4240 KB Output isn't correct
9 Incorrect 0 ms 4240 KB Unexpected end of file - int64 expected
10 Incorrect 0 ms 4240 KB Output isn't correct
11 Incorrect 0 ms 4240 KB Unexpected end of file - int64 expected
12 Incorrect 0 ms 4240 KB Output isn't correct
13 Incorrect 0 ms 4240 KB Output isn't correct
14 Incorrect 0 ms 4240 KB Unexpected end of file - int64 expected
15 Incorrect 0 ms 4240 KB Unexpected end of file - int64 expected
16 Incorrect 6 ms 4240 KB Output isn't correct
17 Incorrect 6 ms 4240 KB Unexpected end of file - int64 expected
18 Incorrect 6 ms 4240 KB Unexpected end of file - int64 expected
19 Incorrect 6 ms 4240 KB Unexpected end of file - int64 expected
20 Correct 3 ms 4240 KB Output is correct
21 Incorrect 26 ms 4240 KB Output isn't correct
22 Incorrect 23 ms 4240 KB Output isn't correct
23 Incorrect 26 ms 4240 KB Unexpected end of file - int64 expected
24 Incorrect 39 ms 4240 KB Unexpected end of file - int64 expected
25 Incorrect 16 ms 4240 KB Output isn't correct
26 Incorrect 36 ms 4240 KB Unexpected end of file - int64 expected
27 Incorrect 43 ms 4240 KB Unexpected end of file - int64 expected
28 Incorrect 33 ms 4240 KB Output isn't correct
29 Incorrect 26 ms 4240 KB Output isn't correct
30 Incorrect 9 ms 4240 KB Output isn't correct
31 Correct 0 ms 4240 KB Output is correct
32 Incorrect 0 ms 4240 KB Unexpected end of file - int64 expected