Submission #708601

# Submission time Handle Problem Language Result Execution time Memory
708601 2023-03-12T04:17:43 Z ntdxl05 Gap (APIO16_gap) C++14
70 / 100
63 ms 4364 KB
#include <bits/stdc++.h>
using namespace std;
#include "gap.h"

const long long inf = 1e18;

template<class U, class V>
bool maxz(U &a, V b) {
	if (a < b) return a = b, 1;
	return 0;
}

long long findGap(int T, int N) {
	long long x, y;
	MinMax(0, inf, &x, &y);

	long long z = (y - x - 1) / (N - 1), t = (y - x - 1) % (N - 1);
	vector<pair<long long, long long>> vv{pair<long long, long long>{0, x}};
	long long l = x + 1;
	for (int i = 0; i < N - 1; i++) {
		long long r = l + z + (i < t);
		vv.push_back({l, r - 1});
		// cerr << l << " " << r - 1 << "\n";
		l = r;
	}
	vv.push_back({y, inf});
	int m = vv.size();
	vector<pair<long long, long long>> h(m, {-1, -1});
	h[0] = {-1, x};
	h[m - 1] = {y, -1};
	long long res = 0;
	for (int i = 1; i + 1 < m; i++) {
		if (vv[i].first <= vv[i].second) {
			MinMax(vv[i].first, vv[i].second, &x, &y);
			h[i] = {x, y};
		}
	}

	for (int l = 1, r = 1; l + 1 < m; l = r) {
		for (; r + 1 < m && h[r] == h[l]; r++);
		if (h[l].first == -1) {
			long long gap = h[r].first - h[l - 1].second;
			maxz(res, gap);
		}
	}

	return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Output isn't correct
2 Incorrect 0 ms 208 KB Output isn't correct
3 Incorrect 1 ms 208 KB Output isn't correct
4 Incorrect 1 ms 208 KB Output isn't correct
5 Incorrect 0 ms 208 KB Output isn't correct
6 Incorrect 0 ms 208 KB Output isn't correct
7 Incorrect 0 ms 208 KB Output isn't correct
8 Incorrect 0 ms 208 KB Output isn't correct
9 Incorrect 1 ms 208 KB Output isn't correct
10 Incorrect 0 ms 208 KB Output isn't correct
11 Incorrect 2 ms 336 KB Output isn't correct
12 Incorrect 2 ms 336 KB Output isn't correct
13 Incorrect 1 ms 336 KB Output isn't correct
14 Incorrect 1 ms 336 KB Output isn't correct
15 Incorrect 1 ms 336 KB Output isn't correct
16 Incorrect 14 ms 1352 KB Output isn't correct
17 Incorrect 13 ms 1444 KB Output isn't correct
18 Incorrect 12 ms 1352 KB Output isn't correct
19 Incorrect 12 ms 1420 KB Output isn't correct
20 Incorrect 7 ms 1372 KB Output isn't correct
21 Incorrect 63 ms 4296 KB Output isn't correct
22 Incorrect 50 ms 4280 KB Output isn't correct
23 Incorrect 55 ms 4248 KB Output isn't correct
24 Incorrect 59 ms 4312 KB Output isn't correct
25 Incorrect 55 ms 4248 KB Output isn't correct
26 Incorrect 58 ms 4256 KB Output isn't correct
27 Incorrect 50 ms 4364 KB Output isn't correct
28 Incorrect 51 ms 4256 KB Output isn't correct
29 Incorrect 52 ms 4268 KB Output isn't correct
30 Incorrect 28 ms 4288 KB Output isn't correct
31 Incorrect 1 ms 208 KB Output isn't correct
32 Incorrect 0 ms 208 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 13 ms 1316 KB Output is correct
17 Correct 12 ms 1352 KB Output is correct
18 Correct 12 ms 1364 KB Output is correct
19 Correct 12 ms 1352 KB Output is correct
20 Correct 7 ms 1352 KB Output is correct
21 Correct 50 ms 4240 KB Output is correct
22 Correct 52 ms 4244 KB Output is correct
23 Correct 51 ms 4280 KB Output is correct
24 Correct 50 ms 4244 KB Output is correct
25 Correct 46 ms 4352 KB Output is correct
26 Correct 53 ms 4244 KB Output is correct
27 Correct 49 ms 4348 KB Output is correct
28 Correct 58 ms 4252 KB Output is correct
29 Correct 54 ms 4340 KB Output is correct
30 Correct 37 ms 4284 KB Output is correct
31 Correct 1 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct