답안 #37722

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
37722 2017-12-27T08:59:56 Z szawinis Gap (APIO16_gap) C++14
100 / 100
106 ms 5800 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll findGap(int t, int n) {
	ll ans = 0;
	if(t == 1) {
		ll l = 0, r = 1e18;
		ll a[n+1];
		for(int i = 1; i <= n+1 >> 1; i++) {
			MinMax(l, r, &l, &r);
			a[i] = l;
			a[n-i+1] = r;
			++l, --r;
		}
		for(int i = 1; i < n; i++) ans = max(a[i+1] - a[i], ans);
	} else {
		ll l = 0, r = 1e18;
		MinMax(l, r, &l, &r);
		ll blk = (r-l+n-2) / (n-1);
		assert(blk >= 1);
		ll x = l, pre = 0;
		while(x < r) {
			ll tmpl, tmpr;
			MinMax(x, x+blk-1, &tmpl, &tmpr);
			if(tmpl == -1 && tmpr == -1) {
				x += blk;
				continue;
			}
			if(x != l) ans = max(tmpl - pre, ans);
			pre = tmpr;
			x += blk;
		}
		if(x == r) ans = max(x - pre, ans);
	}
	return ans;
}

Compilation message

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:11:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   for(int i = 1; i <= n+1 >> 1; i++) {
                        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5140 KB Output is correct
2 Correct 0 ms 5140 KB Output is correct
3 Correct 0 ms 5140 KB Output is correct
4 Correct 0 ms 5140 KB Output is correct
5 Correct 0 ms 5140 KB Output is correct
6 Correct 0 ms 5140 KB Output is correct
7 Correct 0 ms 5140 KB Output is correct
8 Correct 0 ms 5140 KB Output is correct
9 Correct 0 ms 5140 KB Output is correct
10 Correct 0 ms 5140 KB Output is correct
11 Correct 0 ms 5140 KB Output is correct
12 Correct 0 ms 5140 KB Output is correct
13 Correct 0 ms 5140 KB Output is correct
14 Correct 0 ms 5140 KB Output is correct
15 Correct 0 ms 5140 KB Output is correct
16 Correct 9 ms 5208 KB Output is correct
17 Correct 13 ms 5212 KB Output is correct
18 Correct 13 ms 5212 KB Output is correct
19 Correct 6 ms 5212 KB Output is correct
20 Correct 9 ms 5208 KB Output is correct
21 Correct 49 ms 5796 KB Output is correct
22 Correct 56 ms 5796 KB Output is correct
23 Correct 59 ms 5800 KB Output is correct
24 Correct 63 ms 5800 KB Output is correct
25 Correct 66 ms 5792 KB Output is correct
26 Correct 53 ms 5796 KB Output is correct
27 Correct 66 ms 5796 KB Output is correct
28 Correct 56 ms 5800 KB Output is correct
29 Correct 56 ms 5796 KB Output is correct
30 Correct 49 ms 5796 KB Output is correct
31 Correct 0 ms 5140 KB Output is correct
32 Correct 0 ms 5140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5140 KB Output is correct
2 Correct 0 ms 5140 KB Output is correct
3 Correct 0 ms 5140 KB Output is correct
4 Correct 0 ms 5140 KB Output is correct
5 Correct 0 ms 5140 KB Output is correct
6 Correct 0 ms 5140 KB Output is correct
7 Correct 0 ms 5140 KB Output is correct
8 Correct 0 ms 5140 KB Output is correct
9 Correct 0 ms 5140 KB Output is correct
10 Correct 0 ms 5140 KB Output is correct
11 Correct 0 ms 5140 KB Output is correct
12 Correct 0 ms 5140 KB Output is correct
13 Correct 0 ms 5140 KB Output is correct
14 Correct 0 ms 5140 KB Output is correct
15 Correct 0 ms 5140 KB Output is correct
16 Correct 26 ms 5140 KB Output is correct
17 Correct 23 ms 5140 KB Output is correct
18 Correct 19 ms 5140 KB Output is correct
19 Correct 13 ms 5140 KB Output is correct
20 Correct 9 ms 5140 KB Output is correct
21 Correct 79 ms 5140 KB Output is correct
22 Correct 103 ms 5140 KB Output is correct
23 Correct 89 ms 5140 KB Output is correct
24 Correct 83 ms 5140 KB Output is correct
25 Correct 79 ms 5140 KB Output is correct
26 Correct 69 ms 5140 KB Output is correct
27 Correct 83 ms 5140 KB Output is correct
28 Correct 86 ms 5140 KB Output is correct
29 Correct 106 ms 5140 KB Output is correct
30 Correct 43 ms 5140 KB Output is correct
31 Correct 0 ms 5140 KB Output is correct
32 Correct 0 ms 5140 KB Output is correct