Submission #744320

# Submission time Handle Problem Language Result Execution time Memory
744320 2023-05-18T12:07:43 Z b00norp Gap (APIO16_gap) C++14
100 / 100
60 ms 1900 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;

const long long INF = 1e18;

long long findGap(int T, int N)
{
	if(T == 1)
	{	
		long long mn = 0, mx = INF;
		vector<long long> a(N);
		int l = 0, r = N - 1;
		while(l <= r)
		{
			MinMax(mn, mx, &mn, &mx);
			// cout << "mn = " << mn << ", mx = " << mx << "\n";
			a[l++] = mn;
			a[r--] = mx;
			mn += 1;
			mx -= 1;
		}
		long long diff = 0;
		for(int i = 1; i < N; i++)
		{
			diff = max(diff, a[i] - a[i - 1]);
		}
		return diff;
	}
	long long mn = 0, mx = INF;
	MinMax(mn, mx, &mn, &mx);
	long long min_diff = (mx - mn) / (N - 1) + 1;
	long long ans = 0, prev = -INF;
	for(long long i = mn; i <= mx; i += min_diff)
	{
		long long l, r;
		MinMax(i, i + min_diff - 1, &l, &r);
		if(l == -1)
		{
			continue;
		}
		if(prev == -INF)
		{
			prev = l;
		}
		ans = max(ans, l - prev);
		ans = max(ans, r - l);
		prev = r;
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 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 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 0 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 1 ms 352 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 10 ms 684 KB Output is correct
17 Correct 11 ms 680 KB Output is correct
18 Correct 11 ms 608 KB Output is correct
19 Correct 9 ms 684 KB Output is correct
20 Correct 7 ms 720 KB Output is correct
21 Correct 36 ms 1864 KB Output is correct
22 Correct 39 ms 1828 KB Output is correct
23 Correct 36 ms 1788 KB Output is correct
24 Correct 47 ms 1900 KB Output is correct
25 Correct 32 ms 1828 KB Output is correct
26 Correct 46 ms 1824 KB Output is correct
27 Correct 36 ms 1864 KB Output is correct
28 Correct 38 ms 1824 KB Output is correct
29 Correct 38 ms 1856 KB Output is correct
30 Correct 31 ms 1808 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 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 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 13 ms 512 KB Output is correct
17 Correct 13 ms 428 KB Output is correct
18 Correct 13 ms 464 KB Output is correct
19 Correct 12 ms 460 KB Output is correct
20 Correct 6 ms 516 KB Output is correct
21 Correct 60 ms 1080 KB Output is correct
22 Correct 56 ms 1056 KB Output is correct
23 Correct 59 ms 1088 KB Output is correct
24 Correct 54 ms 1076 KB Output is correct
25 Correct 48 ms 1084 KB Output is correct
26 Correct 53 ms 1060 KB Output is correct
27 Correct 54 ms 1056 KB Output is correct
28 Correct 58 ms 1064 KB Output is correct
29 Correct 56 ms 1036 KB Output is correct
30 Correct 27 ms 1068 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct