Submission #744817

# Submission time Handle Problem Language Result Execution time Memory
744817 2023-05-19T06:22:13 Z Suvd Gap (APIO16_gap) C++14
100 / 100
58 ms 1872 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const long long INF = 1e18;
 
long long findGap(int T, int N){
	if(T==1){
		ll mn = 0, mx = INF;
		int l=0,r=N-1;
		vector<ll>a(N);
		while(l <= r){
			MinMax(mn,mx,&mn,&mx);
			a[l++]=mn;
			a[r--]=mx;
			mn+=1;mx-=1;
		}
		ll diff = 0;
		for(int i=1;i<N;i++){
			diff=max(diff,a[i]-a[i-1]);
		}
		return diff;
	}
	ll mn = 0, mx = INF;
	MinMax(mn,mx,&mn,&mx);
	ll min_diff = (mx - mn) / (N - 1) + 1;
	ll ans = 0, prev = -INF;
	for(ll i = mn; i <= mx; i += min_diff){
		ll 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 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 0 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 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 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 9 ms 636 KB Output is correct
17 Correct 9 ms 720 KB Output is correct
18 Correct 10 ms 604 KB Output is correct
19 Correct 10 ms 684 KB Output is correct
20 Correct 8 ms 720 KB Output is correct
21 Correct 36 ms 1864 KB Output is correct
22 Correct 37 ms 1872 KB Output is correct
23 Correct 38 ms 1772 KB Output is correct
24 Correct 38 ms 1828 KB Output is correct
25 Correct 31 ms 1864 KB Output is correct
26 Correct 37 ms 1808 KB Output is correct
27 Correct 36 ms 1872 KB Output is correct
28 Correct 38 ms 1772 KB Output is correct
29 Correct 38 ms 1812 KB Output is correct
30 Correct 30 ms 1832 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 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 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 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 336 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 14 ms 508 KB Output is correct
17 Correct 12 ms 424 KB Output is correct
18 Correct 12 ms 396 KB Output is correct
19 Correct 12 ms 464 KB Output is correct
20 Correct 7 ms 464 KB Output is correct
21 Correct 56 ms 1172 KB Output is correct
22 Correct 58 ms 968 KB Output is correct
23 Correct 50 ms 1080 KB Output is correct
24 Correct 51 ms 1060 KB Output is correct
25 Correct 46 ms 1084 KB Output is correct
26 Correct 55 ms 1052 KB Output is correct
27 Correct 52 ms 964 KB Output is correct
28 Correct 52 ms 1084 KB Output is correct
29 Correct 51 ms 1060 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