Submission #94529

# Submission time Handle Problem Language Result Execution time Memory
94529 2019-01-19T21:47:38 Z hugo_pm Gap (APIO16_gap) C++14
100 / 100
61 ms 1916 KB
#include "gap.h"
#include <vector>
#include <iostream>
using namespace std;

typedef long long llg;

vector<llg> a;

llg s1(int n)
{
	a.resize(n);
	llg x = 0, y = (llg)(1e18);
	int d = 0, f = n-1;
	while (d <= f) {
		MinMax(x, y, &x, &y);
		a[d] = x;
		a[f] = y;
		++x; ++d;
		--y; --f;
	}
	llg r = 0;
	for (int i = 0; i < (n-1); ++i) {
		r = max(r, a[i+1] - a[i]);
	}
	return r;
}

llg s2(int n)
{
	llg amin, amax;
	MinMax(0, (llg)(1e18), &amin, &amax);
	llg totSize = amax-amin+1-2;
	llg sizeBloc = totSize/(n-1);
	llg deb = 0, fin = amin;
	llg ans = 0, der = amin;

	for (int iBloc = 0; iBloc < (n-1); ++iBloc) {
		deb = fin+1;
		fin = deb+sizeBloc-1;
		if (iBloc <= (totSize) % (n-1)) ++fin;
		llg xl, xr;
		MinMax(deb, fin, &xl, &xr);
		if (xl != -1) {
			if (der != -1) ans = max(ans, xl - der);
			der = xr;
		}
	}
	ans = max(ans, amax - der);
	return ans;
}

llg findGap(int t, int n)
{
	if (t == 1) return s1(n);
	else return s2(n);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 12 ms 760 KB Output is correct
17 Correct 12 ms 760 KB Output is correct
18 Correct 13 ms 760 KB Output is correct
19 Correct 13 ms 760 KB Output is correct
20 Correct 9 ms 760 KB Output is correct
21 Correct 45 ms 1916 KB Output is correct
22 Correct 45 ms 1912 KB Output is correct
23 Correct 48 ms 1912 KB Output is correct
24 Correct 46 ms 1912 KB Output is correct
25 Correct 40 ms 1912 KB Output is correct
26 Correct 46 ms 1912 KB Output is correct
27 Correct 48 ms 1912 KB Output is correct
28 Correct 46 ms 1912 KB Output is correct
29 Correct 45 ms 1884 KB Output is correct
30 Correct 34 ms 1912 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 3 ms 380 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 15 ms 504 KB Output is correct
17 Correct 17 ms 504 KB Output is correct
18 Correct 15 ms 504 KB Output is correct
19 Correct 15 ms 504 KB Output is correct
20 Correct 8 ms 504 KB Output is correct
21 Correct 61 ms 1144 KB Output is correct
22 Correct 58 ms 1144 KB Output is correct
23 Correct 60 ms 1144 KB Output is correct
24 Correct 60 ms 1272 KB Output is correct
25 Correct 56 ms 1144 KB Output is correct
26 Correct 59 ms 1272 KB Output is correct
27 Correct 60 ms 1128 KB Output is correct
28 Correct 61 ms 1400 KB Output is correct
29 Correct 61 ms 1160 KB Output is correct
30 Correct 34 ms 1144 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct