Submission #107612

# Submission time Handle Problem Language Result Execution time Memory
107612 2019-04-25T10:02:39 Z Minnakhmetov Gap (APIO16_gap) C++14
78.541 / 100
80 ms 3816 KB
#include "gap.h"
#include <algorithm>
#include <vector>
using namespace std;

#define ll long long
const ll MAX = 1e18;
const int N = 1e5 + 5;
ll a[N];

long long findGap(int t, int n)
{
	ll ans = 1;

	if (t == 1) {
		ll l = 0, r = MAX;
		int x = 0, y = n - 1;
		while (x <= y) {
			MinMax(l, r, &a[x], &a[y]);
			l = a[x] + 1;
			r = a[y] - 1;
			x++;
			y--;
		}
		for (int i = 0; i < n - 1; i++)
			ans = max(ans, a[i + 1] - a[i]);
	}
	else {
		ll L, R, mn, mx, x;
		MinMax(0, MAX, &L, &R);

		x = (R - L) / (n - 1);

		vector<pair<ll, ll>> v;
		for (ll i = L; i <= R; i += x) {
			MinMax(i, i + x, &mn, &mx);
			if (mn != -1) {
				v.push_back({ mn, mx });
				ans = max(ans, mx - mn);
			}
		}

		for (int i = 1; i < v.size(); i++) {
			ans = max(ans, v[i].first - v[i - 1].second);
		}
	}

	return ans;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:43:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 1; i < v.size(); i++) {
                   ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 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 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 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 15 ms 1004 KB Output is correct
17 Correct 18 ms 1016 KB Output is correct
18 Correct 16 ms 1024 KB Output is correct
19 Correct 15 ms 1024 KB Output is correct
20 Correct 10 ms 768 KB Output is correct
21 Correct 50 ms 2424 KB Output is correct
22 Correct 52 ms 2424 KB Output is correct
23 Correct 49 ms 2424 KB Output is correct
24 Correct 53 ms 2424 KB Output is correct
25 Correct 42 ms 2424 KB Output is correct
26 Correct 56 ms 2396 KB Output is correct
27 Correct 47 ms 2424 KB Output is correct
28 Correct 52 ms 2424 KB Output is correct
29 Correct 46 ms 2424 KB Output is correct
30 Correct 34 ms 2424 KB Output is correct
31 Correct 2 ms 356 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 384 KB Partially correct
2 Partially correct 2 ms 256 KB Partially correct
3 Partially correct 2 ms 256 KB Partially correct
4 Partially correct 3 ms 384 KB Partially correct
5 Partially correct 2 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 2 ms 384 KB Partially correct
10 Partially correct 2 ms 384 KB Partially correct
11 Partially correct 3 ms 384 KB Partially correct
12 Partially correct 3 ms 384 KB Partially correct
13 Partially correct 4 ms 384 KB Partially correct
14 Partially correct 3 ms 384 KB Partially correct
15 Partially correct 4 ms 384 KB Partially correct
16 Partially correct 30 ms 1280 KB Partially correct
17 Partially correct 19 ms 1152 KB Partially correct
18 Partially correct 26 ms 1152 KB Partially correct
19 Partially correct 18 ms 1280 KB Partially correct
20 Partially correct 10 ms 512 KB Partially correct
21 Partially correct 80 ms 2820 KB Partially correct
22 Partially correct 73 ms 2800 KB Partially correct
23 Partially correct 66 ms 2888 KB Partially correct
24 Partially correct 66 ms 2672 KB Partially correct
25 Partially correct 75 ms 3816 KB Partially correct
26 Partially correct 63 ms 2952 KB Partially correct
27 Partially correct 64 ms 2800 KB Partially correct
28 Partially correct 63 ms 2800 KB Partially correct
29 Partially correct 75 ms 2800 KB Partially correct
30 Partially correct 35 ms 2064 KB Partially correct
31 Partially correct 3 ms 256 KB Partially correct
32 Partially correct 2 ms 384 KB Partially correct