답안 #909819

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
909819 2024-01-17T12:55:24 Z oblantis Gap (APIO16_gap) C++17
100 / 100
41 ms 3644 KB
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "gap.h"
#define all(v) v.begin(), v.end()
#define pb push_back
#define ss second
#define ff first
#define vt vector
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll inf = 1e18;
const int mod = 1e9+7;
const int maxn = 1e5 + 1;
//void MinMax(long long s, long long t, long long *mn, long long *mx)
//{
	//int lo = 1, hi = N, left = N+1, right = 0;
	//while (lo <= hi){
		//int mid = (lo+hi)>>1;
		//if (A[mid] >= s) hi = mid - 1, left = mid;
		//else lo = mid + 1;
	//}
	//lo = 1, hi = N;
	//while (lo <= hi){
		//int mid = (lo+hi)>>1;
		//if (A[mid] <= t) lo = mid + 1, right = mid;
		//else hi = mid - 1;
	//}
	//if (left > right) *mn = *mx = -1;
	//else{
		//*mn = A[left];
		//*mx = A[right];
	//}
//}
long long findGap(int t, int n){
	ll l = 0, r = inf;
	if(t == 1){
		ll a[n];
		int xl = 0, xr = n - 1;
		while(xl <= xr){
			MinMax(l, r, &l, &r);
			a[xl] = l, a[xr] = r;
			l++, r--;
			xl++, xr--;
		}
		ll ret = 1;
		for(int i = 1; i < n; i++){
			ret = max(ret, a[i] - a[i - 1]);
		}
		return ret;
	}
	MinMax(0, inf, &l, &r);
	ll x = l + 1, bf = l;
	ll ret = (r - l + n - 2) / (n - 1);
	while(x < r){
		ll mn = -1, mx = -1;
		while(mn == -1){
			MinMax(x, x + ret, &mn, &mx);
			if(mn == -1)x = x + ret + 1;
		}
		ret = max(ret, mn - bf);
		bf = mx;
		x = bf + 1;
	}
	return ret;
}
//int main(){
	//cin >> N >> N;
	//for(int i = 1; i <= N; i++){
		//cin >> A[i];
	//}
	//cout << findGap(N, N);
	//return 0;
//}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 2 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 2 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 7 ms 2572 KB Output is correct
17 Correct 8 ms 2588 KB Output is correct
18 Correct 8 ms 2744 KB Output is correct
19 Correct 9 ms 2792 KB Output is correct
20 Correct 6 ms 2764 KB Output is correct
21 Correct 30 ms 3448 KB Output is correct
22 Correct 29 ms 3624 KB Output is correct
23 Correct 28 ms 3612 KB Output is correct
24 Correct 29 ms 3624 KB Output is correct
25 Correct 30 ms 3644 KB Output is correct
26 Correct 30 ms 3640 KB Output is correct
27 Correct 30 ms 3632 KB Output is correct
28 Correct 29 ms 3624 KB Output is correct
29 Correct 29 ms 3620 KB Output is correct
30 Correct 26 ms 3640 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2404 KB Output is correct
6 Correct 1 ms 2404 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2548 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 2548 KB Output is correct
14 Correct 2 ms 2400 KB Output is correct
15 Correct 2 ms 2400 KB Output is correct
16 Correct 6 ms 2584 KB Output is correct
17 Correct 5 ms 2696 KB Output is correct
18 Correct 5 ms 2588 KB Output is correct
19 Correct 5 ms 2592 KB Output is correct
20 Correct 4 ms 2576 KB Output is correct
21 Correct 17 ms 2876 KB Output is correct
22 Correct 21 ms 2800 KB Output is correct
23 Correct 23 ms 2872 KB Output is correct
24 Correct 19 ms 1208 KB Output is correct
25 Correct 41 ms 2852 KB Output is correct
26 Correct 18 ms 2856 KB Output is correct
27 Correct 22 ms 2856 KB Output is correct
28 Correct 18 ms 3112 KB Output is correct
29 Correct 19 ms 2868 KB Output is correct
30 Correct 13 ms 2852 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2400 KB Output is correct