Submission #20633

# Submission time Handle Problem Language Result Execution time Memory
20633 2017-02-13T04:44:38 Z model_code Gap (APIO16_gap) C++14
100 / 100
73 ms 4240 KB
/*
 * Author: Gyeonggeun Kim(kriii)
 * Time Complexity: O(N lg N)
 */
#include "gap.h"
#include <algorithm>
using namespace std;

long long findGap(int T, int N)
{
	long long mn, mx;
	long long ans = 0;
	MinMax(0,2e18,&mn,&mx);

	if (T == 1){
		for (int i=1;i<(N+1)/2;i++){
			long long mmn, mmx;
			MinMax(mn+1,mx-1,&mmn,&mmx);
			ans = max(ans,mmn-mn);
			ans = max(ans,mx-mmx);
			mn = mmn;
			mx = mmx;
		}
		ans = max(ans,mx-mn);
	}
	else{
		long long sz = (mx - mn + N - 1) / N;
		long long last = mn;
		for (long long s=mn+1,e=mn+sz,i=0;i<N;s+=sz,e+=sz,i++){
			if (e >= mx) e = mx - 1;
			if (s > e) break;
			long long mmn, mmx;
			MinMax(s,e,&mmn,&mmx);
			if (mmn != -1){
				ans = max(ans,mmn-last);
				last = mmx;
			}
		}
		ans = max(ans,mx-last);
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4240 KB Output is correct
2 Correct 0 ms 4240 KB Output is correct
3 Correct 0 ms 4240 KB Output is correct
4 Correct 0 ms 4240 KB Output is correct
5 Correct 0 ms 4240 KB Output is correct
6 Correct 0 ms 4240 KB Output is correct
7 Correct 0 ms 4240 KB Output is correct
8 Correct 0 ms 4240 KB Output is correct
9 Correct 0 ms 4240 KB Output is correct
10 Correct 0 ms 4240 KB Output is correct
11 Correct 0 ms 4240 KB Output is correct
12 Correct 0 ms 4240 KB Output is correct
13 Correct 0 ms 4240 KB Output is correct
14 Correct 0 ms 4240 KB Output is correct
15 Correct 0 ms 4240 KB Output is correct
16 Correct 9 ms 4240 KB Output is correct
17 Correct 13 ms 4240 KB Output is correct
18 Correct 13 ms 4240 KB Output is correct
19 Correct 13 ms 4240 KB Output is correct
20 Correct 9 ms 4240 KB Output is correct
21 Correct 56 ms 4240 KB Output is correct
22 Correct 46 ms 4240 KB Output is correct
23 Correct 49 ms 4240 KB Output is correct
24 Correct 59 ms 4240 KB Output is correct
25 Correct 46 ms 4240 KB Output is correct
26 Correct 56 ms 4240 KB Output is correct
27 Correct 53 ms 4240 KB Output is correct
28 Correct 49 ms 4240 KB Output is correct
29 Correct 53 ms 4240 KB Output is correct
30 Correct 39 ms 4240 KB Output is correct
31 Correct 0 ms 4240 KB Output is correct
32 Correct 0 ms 4240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4240 KB Output is correct
2 Correct 0 ms 4240 KB Output is correct
3 Correct 0 ms 4240 KB Output is correct
4 Correct 0 ms 4240 KB Output is correct
5 Correct 0 ms 4240 KB Output is correct
6 Correct 0 ms 4240 KB Output is correct
7 Correct 0 ms 4240 KB Output is correct
8 Correct 0 ms 4240 KB Output is correct
9 Correct 0 ms 4240 KB Output is correct
10 Correct 0 ms 4240 KB Output is correct
11 Correct 0 ms 4240 KB Output is correct
12 Correct 0 ms 4240 KB Output is correct
13 Correct 0 ms 4240 KB Output is correct
14 Correct 0 ms 4240 KB Output is correct
15 Correct 0 ms 4240 KB Output is correct
16 Correct 9 ms 4240 KB Output is correct
17 Correct 13 ms 4240 KB Output is correct
18 Correct 13 ms 4240 KB Output is correct
19 Correct 16 ms 4240 KB Output is correct
20 Correct 6 ms 4240 KB Output is correct
21 Correct 73 ms 4240 KB Output is correct
22 Correct 73 ms 4240 KB Output is correct
23 Correct 73 ms 4240 KB Output is correct
24 Correct 63 ms 4240 KB Output is correct
25 Correct 66 ms 4240 KB Output is correct
26 Correct 69 ms 4240 KB Output is correct
27 Correct 69 ms 4240 KB Output is correct
28 Correct 69 ms 4240 KB Output is correct
29 Correct 73 ms 4240 KB Output is correct
30 Correct 39 ms 4240 KB Output is correct
31 Correct 0 ms 4240 KB Output is correct
32 Correct 0 ms 4240 KB Output is correct