Submission #953933

# Submission time Handle Problem Language Result Execution time Memory
953933 2024-03-26T22:37:10 Z 4QT0R Gap (APIO16_gap) C++17
100 / 100
46 ms 3328 KB
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
#define ll long long

ll findGap(int T, int n){
	ll L,P;
	MinMax(0,1e18,&L,&P);
	ll d=(P-L+n-2)/(n-1);
	ll ans=d,x,y;
	if (T==1){
		for (ll i = 1; i<(n+1)/2; i++){
			if (L+1==P)break;
			MinMax(L+1,P-1,&x,&y);
			if (x==-1){
				ans=max(ans,P-L);
				break;
			}
			else ans=max({ans,x-L,P-y});
			L=x;
			P=y;
		}
	}
	else{
		ll iter,l=L;
		for (iter = L; iter+d<P; iter+=d+1){
			MinMax(iter,iter+d,&x,&y);
			if (x!=-1){
				ans=max(ans,x-l);
				l=y;
			}
		}
		MinMax(iter,P,&x,&y);
		if (x!=-1){
			ans=max(ans,x-l);
		}
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 2 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2552 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 0 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2496 KB Output is correct
16 Correct 8 ms 2580 KB Output is correct
17 Correct 7 ms 2584 KB Output is correct
18 Correct 7 ms 2592 KB Output is correct
19 Correct 8 ms 2656 KB Output is correct
20 Correct 6 ms 2536 KB Output is correct
21 Correct 30 ms 3328 KB Output is correct
22 Correct 29 ms 2860 KB Output is correct
23 Correct 28 ms 2852 KB Output is correct
24 Correct 30 ms 2852 KB Output is correct
25 Correct 27 ms 2848 KB Output is correct
26 Correct 29 ms 2976 KB Output is correct
27 Correct 29 ms 2852 KB Output is correct
28 Correct 29 ms 3024 KB Output is correct
29 Correct 29 ms 3048 KB Output is correct
30 Correct 25 ms 2752 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 2 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 0 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 2 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 10 ms 2680 KB Output is correct
17 Correct 11 ms 2584 KB Output is correct
18 Correct 10 ms 2580 KB Output is correct
19 Correct 10 ms 2580 KB Output is correct
20 Correct 5 ms 2572 KB Output is correct
21 Correct 40 ms 2860 KB Output is correct
22 Correct 46 ms 2860 KB Output is correct
23 Correct 41 ms 3088 KB Output is correct
24 Correct 40 ms 2856 KB Output is correct
25 Correct 40 ms 2852 KB Output is correct
26 Correct 40 ms 2856 KB Output is correct
27 Correct 41 ms 2856 KB Output is correct
28 Correct 41 ms 2856 KB Output is correct
29 Correct 40 ms 2860 KB Output is correct
30 Correct 22 ms 2852 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct