Submission #96322

# Submission time Handle Problem Language Result Execution time Memory
96322 2019-02-08T13:04:41 Z jamielim Gap (APIO16_gap) C++14
100 / 100
83 ms 2680 KB
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
 
long long findGap(int T,int N){
	if(T==1){
		long long arr[N];
		int a=0,b=N-1;
		long long s=0,t=1000000000000000000;
		long long mn,mx;
		while(a<=b){
			MinMax(s,t,&mn,&mx);
			arr[a]=mn;
			arr[b]=mx;
			s=mn+1;
			t=mx-1;
			a++; b--;
		}
		long long ans=0;
		for(int i=1;i<N;i++){
			ans=max(ans,arr[i]-arr[i-1]);
		}
		return ans;
	}else{
		long long s=0,t=1000000000000000000;
		long long mn,mx;
		MinMax(s,t,&mn,&mx);
		if(N==2)return mx-mn;
		long long k=mx-mn+1;
		s=mn+1;
		long long prev=mn,ans=0;
		for(int i=0;i<N-1;i++){
			t=s+(k/(N-1));
			MinMax(s,t,&mn,&mx);
			if(mn!=-1){
				ans=max(ans,mn-prev);
				prev=mx;
			}
			s=t+1;
		}
		return ans;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 2 ms 392 KB Output is correct
13 Correct 2 ms 380 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 13 ms 1144 KB Output is correct
17 Correct 12 ms 1016 KB Output is correct
18 Correct 13 ms 988 KB Output is correct
19 Correct 13 ms 1016 KB Output is correct
20 Correct 9 ms 760 KB Output is correct
21 Correct 50 ms 2480 KB Output is correct
22 Correct 46 ms 2552 KB Output is correct
23 Correct 50 ms 2680 KB Output is correct
24 Correct 47 ms 2604 KB Output is correct
25 Correct 40 ms 2596 KB Output is correct
26 Correct 47 ms 2552 KB Output is correct
27 Correct 53 ms 2552 KB Output is correct
28 Correct 60 ms 2680 KB Output is correct
29 Correct 48 ms 2552 KB Output is correct
30 Correct 42 ms 2424 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 252 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 16 ms 888 KB Output is correct
17 Correct 16 ms 888 KB Output is correct
18 Correct 16 ms 1016 KB Output is correct
19 Correct 17 ms 888 KB Output is correct
20 Correct 8 ms 504 KB Output is correct
21 Correct 63 ms 1784 KB Output is correct
22 Correct 63 ms 1912 KB Output is correct
23 Correct 64 ms 1784 KB Output is correct
24 Correct 66 ms 2012 KB Output is correct
25 Correct 57 ms 1784 KB Output is correct
26 Correct 62 ms 1784 KB Output is correct
27 Correct 83 ms 1784 KB Output is correct
28 Correct 73 ms 1756 KB Output is correct
29 Correct 62 ms 1784 KB Output is correct
30 Correct 33 ms 1656 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct