답안 #20634

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
20634 2017-02-13T04:45:17 Z model_code Gap (APIO16_gap) C++14
83.1305 / 100
79 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;
      long long mmmn, mmmx;
      MinMax(1, 100, &mmmn, &mmmx);
		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;
}
# 결과 실행 시간 메모리 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 13 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 59 ms 4240 KB Output is correct
22 Correct 53 ms 4240 KB Output is correct
23 Correct 49 ms 4240 KB Output is correct
24 Correct 63 ms 4240 KB Output is correct
25 Correct 49 ms 4240 KB Output is correct
26 Correct 46 ms 4240 KB Output is correct
27 Correct 43 ms 4240 KB Output is correct
28 Correct 46 ms 4240 KB Output is correct
29 Correct 53 ms 4240 KB Output is correct
30 Correct 36 ms 4240 KB Output is correct
31 Correct 0 ms 4240 KB Output is correct
32 Correct 0 ms 4240 KB Output is correct
# 결과 실행 시간 메모리 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 Partially correct 0 ms 4240 KB Partially 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 16 ms 4240 KB Output is correct
17 Correct 16 ms 4240 KB Output is correct
18 Correct 16 ms 4240 KB Output is correct
19 Correct 19 ms 4240 KB Output is correct
20 Correct 6 ms 4240 KB Output is correct
21 Correct 63 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 69 ms 4240 KB Output is correct
25 Correct 66 ms 4240 KB Output is correct
26 Correct 63 ms 4240 KB Output is correct
27 Correct 76 ms 4240 KB Output is correct
28 Correct 66 ms 4240 KB Output is correct
29 Correct 79 ms 4240 KB Output is correct
30 Correct 39 ms 4240 KB Output is correct
31 Partially correct 0 ms 4240 KB Partially correct
32 Partially correct 0 ms 4240 KB Partially correct