Submission #107613

# Submission time Handle Problem Language Result Execution time Memory
107613 2019-04-25T10:03:50 Z Minnakhmetov Gap (APIO16_gap) C++14
78.541 / 100
100 ms 3308 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 - 1) / (n - 1) + 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 3 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 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 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 316 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 13 ms 768 KB Output is correct
17 Correct 20 ms 640 KB Output is correct
18 Correct 14 ms 768 KB Output is correct
19 Correct 14 ms 768 KB Output is correct
20 Correct 10 ms 768 KB Output is correct
21 Correct 47 ms 1912 KB Output is correct
22 Correct 48 ms 1820 KB Output is correct
23 Correct 49 ms 1916 KB Output is correct
24 Correct 58 ms 1912 KB Output is correct
25 Correct 48 ms 1884 KB Output is correct
26 Correct 70 ms 1912 KB Output is correct
27 Correct 71 ms 1912 KB Output is correct
28 Correct 49 ms 1912 KB Output is correct
29 Correct 45 ms 1912 KB Output is correct
30 Correct 38 ms 1912 KB Output is correct
31 Correct 2 ms 256 KB Output is correct
32 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 384 KB Partially correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Partially correct 2 ms 384 KB Partially correct
6 Correct 2 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 256 KB Output is correct
10 Correct 3 ms 256 KB Output is correct
11 Correct 3 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 Partially correct 3 ms 384 KB Partially correct
16 Correct 24 ms 896 KB Output is correct
17 Correct 20 ms 896 KB Output is correct
18 Correct 22 ms 896 KB Output is correct
19 Correct 18 ms 896 KB Output is correct
20 Partially correct 8 ms 512 KB Partially correct
21 Correct 63 ms 2264 KB Output is correct
22 Correct 63 ms 2288 KB Output is correct
23 Correct 63 ms 2288 KB Output is correct
24 Correct 69 ms 2288 KB Output is correct
25 Partially correct 74 ms 3308 KB Partially correct
26 Correct 68 ms 2284 KB Output is correct
27 Correct 67 ms 2288 KB Output is correct
28 Correct 66 ms 2288 KB Output is correct
29 Correct 100 ms 2276 KB Output is correct
30 Partially correct 36 ms 1528 KB Partially correct
31 Partially correct 2 ms 256 KB Partially correct
32 Partially correct 2 ms 384 KB Partially correct