Submission #564453

# Submission time Handle Problem Language Result Execution time Memory
564453 2022-05-19T09:01:58 Z penguin133 Gap (APIO16_gap) C++14
100 / 100
65 ms 1868 KB
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
 
long long B[100005];
long long findGap(int T, int N)
{
	if(T == 1){
		long long ans = 0, mini, maxi;
		B[N+1] = (long long)1e18 + 5, B[0] = -1;
		int j = N;
		for(int i=1;i<=j;i++){
			//cout << B[i-1] << " " << B[j+1] << '\n';
			MinMax(B[i-1]+1, B[j+1]-1, &mini, &maxi);
			//cout << mini << '\n';
			B[i] = mini, B[j] = maxi;
			//cout << *mini << " " << *maxi << '\n';
			j--;
		}
		for(int i=1;i<N;i++)ans = max(ans, B[i+1] - B[i]);
		return ans;
	}
	else{
		long long ans = 0, mini, maxi;
		MinMax(0, (long long)1e18, &mini, &maxi);
		long long tmp = maxi - mini - 1;
		if(N == 2)return maxi-mini;
		long long prev = mini, prev2 = mini, tmp2 = maxi;
		for(int i=1;i<=N-1;i++){
			long long x  = tmp/(N-i);
			tmp -= x;
			MinMax(prev2 + 1, prev2 + x, &mini, &maxi);
			//cout << prev2 + 1 << " " << prev2 + x << " " << mini << " " << maxi << '\n';
			if(mini != -1)ans = max(ans, mini - prev), prev = maxi;
			prev2 += x;
		}
		ans = max(ans, tmp2 - prev);
		return ans;
	}
	return 0;
}
# 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 1 ms 236 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 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 348 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 336 KB Output is correct
16 Correct 13 ms 592 KB Output is correct
17 Correct 11 ms 592 KB Output is correct
18 Correct 11 ms 592 KB Output is correct
19 Correct 11 ms 612 KB Output is correct
20 Correct 8 ms 696 KB Output is correct
21 Correct 42 ms 1820 KB Output is correct
22 Correct 42 ms 1820 KB Output is correct
23 Correct 48 ms 1744 KB Output is correct
24 Correct 48 ms 1848 KB Output is correct
25 Correct 40 ms 1836 KB Output is correct
26 Correct 44 ms 1800 KB Output is correct
27 Correct 43 ms 1808 KB Output is correct
28 Correct 38 ms 1820 KB Output is correct
29 Correct 38 ms 1868 KB Output is correct
30 Correct 30 ms 1844 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 0 ms 208 KB Output is correct
3 Correct 1 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 0 ms 208 KB Output is correct
8 Correct 1 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 208 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 14 ms 464 KB Output is correct
17 Correct 15 ms 516 KB Output is correct
18 Correct 14 ms 524 KB Output is correct
19 Correct 13 ms 464 KB Output is correct
20 Correct 7 ms 464 KB Output is correct
21 Correct 56 ms 984 KB Output is correct
22 Correct 57 ms 1056 KB Output is correct
23 Correct 59 ms 1104 KB Output is correct
24 Correct 56 ms 1088 KB Output is correct
25 Correct 48 ms 1044 KB Output is correct
26 Correct 55 ms 968 KB Output is correct
27 Correct 65 ms 1084 KB Output is correct
28 Correct 60 ms 1180 KB Output is correct
29 Correct 55 ms 1084 KB Output is correct
30 Correct 31 ms 984 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct