답안 #340901

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
340901 2020-12-28T13:21:32 Z super_j6 Gap (APIO16_gap) C++14
100 / 100
59 ms 1260 KB
#include "gap.h"
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second
/*
const int mxn = 100000;
int t, n;
ll a[mxn];

void MinMax(ll l, ll r, ll *x, ll *y){
	l = lower_bound(a, a + n, l) - a;
	r = upper_bound(a, a + n, r) - a - 1;
	if(l > r) *x = -1, *y = -1;
	else *x = a[l], *y = a[r];
}
*/
void f(ll l, ll r, ll &x, ll &y){
	MinMax(l, r, &x, &y);
}

ll findGap(int t, int n){
	ll l, r, ret = 0;
	f(0, 1e18, l, r);
	if(t & 1){
		for(ll i = 1, x, y; 2 * i < n && r - l > 1; i++, l = x, r = y){
			f(l + 1, r - 1, x, y);
			if(!~x || !~y) break;
			ret = max({ret, r - y, x - l});
		}
	}else{
		for(ll d = (r - l) / (n - 1), i = l + 1; i < r; i += 2 * d){
			ll x, y;
			f(i, min(r - 1, i + 2 * d - 1), x, y);
			if(~x && ~y) ret = max({ret, x - l, y - x}), l = y;
		}
	}
	ret = max(ret, r - l);
	return ret;
}
/*
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> t >> n;
	
	for(int i = 0; i < n; i++) cin >> a[i];
	
	cout << findGap(t, n) << endl;

	return 0;
}
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 11 ms 696 KB Output is correct
17 Correct 12 ms 492 KB Output is correct
18 Correct 11 ms 492 KB Output is correct
19 Correct 11 ms 492 KB Output is correct
20 Correct 8 ms 492 KB Output is correct
21 Correct 50 ms 1132 KB Output is correct
22 Correct 46 ms 1124 KB Output is correct
23 Correct 44 ms 1132 KB Output is correct
24 Correct 42 ms 1228 KB Output is correct
25 Correct 38 ms 1260 KB Output is correct
26 Correct 43 ms 1132 KB Output is correct
27 Correct 47 ms 1176 KB Output is correct
28 Correct 51 ms 1132 KB Output is correct
29 Correct 43 ms 1132 KB Output is correct
30 Correct 34 ms 1176 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 504 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 11 ms 492 KB Output is correct
17 Correct 13 ms 492 KB Output is correct
18 Correct 11 ms 492 KB Output is correct
19 Correct 11 ms 492 KB Output is correct
20 Correct 8 ms 492 KB Output is correct
21 Correct 45 ms 1132 KB Output is correct
22 Correct 51 ms 1132 KB Output is correct
23 Correct 50 ms 1260 KB Output is correct
24 Correct 59 ms 1132 KB Output is correct
25 Correct 49 ms 1132 KB Output is correct
26 Correct 45 ms 1132 KB Output is correct
27 Correct 46 ms 1132 KB Output is correct
28 Correct 44 ms 1236 KB Output is correct
29 Correct 45 ms 1132 KB Output is correct
30 Correct 28 ms 1204 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct