답안 #793507

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
793507 2023-07-25T23:12:09 Z ToniB Gap (APIO16_gap) C++17
100 / 100
52 ms 3184 KB
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
typedef long long ll;

vector<ll> ans;

ll findGap(int t, int n){
	if(t == 1){
		int L = 0, R = n - 1;
		ll val_l = 1, val_r = 1e18;
		while(L <= R){
			MinMax(val_l, val_r, &val_l, &val_r);
			ans.push_back(val_l);
			if(val_r != val_l) ans.push_back(val_r);
			++L; --R;
			++val_l; --val_r;
		}
	} else {
		ll L = 0, R = 1e18;
		MinMax(L, R, &L, &R);
		ans.push_back(L); ans.push_back(R);
		ll block = (R - L + n - 2) / (n - 1);
		for(ll i = L + 1; i < R; i += block + 1){
			ll val_l = i, val_r = min(R - 1, i + block);
			MinMax(val_l, val_r, &val_l, &val_r);
			if(val_l != -1){
				ans.push_back(val_l);
				ans.push_back(val_r);
			}
		}
	}
	ll ret = 0;
	sort(ans.begin(), ans.end());
	for(int i = 0; i < (int)ans.size() - 1; ++i) ret = max(ret, ans[i + 1] - ans[i]);
	return ret;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 8 ms 808 KB Output is correct
17 Correct 11 ms 808 KB Output is correct
18 Correct 8 ms 848 KB Output is correct
19 Correct 8 ms 848 KB Output is correct
20 Correct 7 ms 848 KB Output is correct
21 Correct 32 ms 2248 KB Output is correct
22 Correct 33 ms 2220 KB Output is correct
23 Correct 38 ms 2240 KB Output is correct
24 Correct 41 ms 2140 KB Output is correct
25 Correct 35 ms 2200 KB Output is correct
26 Correct 38 ms 2240 KB Output is correct
27 Correct 31 ms 2196 KB Output is correct
28 Correct 37 ms 2204 KB Output is correct
29 Correct 37 ms 2144 KB Output is correct
30 Correct 29 ms 2180 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 12 ms 896 KB Output is correct
17 Correct 12 ms 848 KB Output is correct
18 Correct 11 ms 844 KB Output is correct
19 Correct 11 ms 848 KB Output is correct
20 Correct 6 ms 464 KB Output is correct
21 Correct 52 ms 2260 KB Output is correct
22 Correct 45 ms 2160 KB Output is correct
23 Correct 45 ms 2188 KB Output is correct
24 Correct 48 ms 2188 KB Output is correct
25 Correct 43 ms 3184 KB Output is correct
26 Correct 49 ms 2212 KB Output is correct
27 Correct 43 ms 2220 KB Output is correct
28 Correct 44 ms 2204 KB Output is correct
29 Correct 46 ms 2200 KB Output is correct
30 Correct 25 ms 1424 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct