답안 #563756

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
563756 2022-05-18T05:13:53 Z khangal Gap (APIO16_gap) C++14
100 / 100
49 ms 1920 KB
#include "gap.h"
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef double db;
typedef vector<long long> vl;
typedef pair<long long, long long > pl;
#define po pop_back
#define pb push_back
#define mk make_pair
#define lw lower_bound
#define up upper_bound
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define MAX 1e18    
#define MIN -1e18
#define per(i,a,b) for(ll i=b;i>=a;i--)
#define con continue
#define freopen freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.14159265358979323846264338327950288419716939937510582097494459230781640628
// typedef tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// template< typename T>
// using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll N , n, m, mid, res,pos, mn, mx, sum, h1, h2, arr[3234567],arr1[1234567],k, i, j, h, a, x, y, z,par[1234567],ans;
bool used[1234567];
ll tp[1234567];
ll dx[4]={-1,1,0,0},dy[4]={0,0,-1,1},c1[123][123];
//ll jump[22][223456];
//ll lvl[1234567];
//ll bit[1234567];
//ll timer;
//ll st[1234567],endd[1234567];
//ll dp[5005][5005];
ll findGap(int T, int n){
	ll l=0,r=MAX,mn,mx;
	if(T==1){
		for(int i=1;i<=(n+1)/2;i++){
			MinMax(l,r,&mn,&mx);
			arr[i] = mn;
			arr[n+1-i] = mx;
			l = mn+1;
			r = mx-1;
		}
		ans=0;
		for(int i=1;i<n;i++)ans=max(ans,arr[i+1]-arr[i]);
		return ans;
	}
	else{
		MinMax(l,r,&mn,&mx);
		l=mn;
		r=mx;
		ans = ceil((mx-mn+1)/n);
		while(l!=r){
			MinMax(l+1,l+ans,&mn,&mx);
			if(mx != -1){
				l=mx;
			}
			else{
				x=ans;
				while(mn==-1){
					x*=2;
					MinMax(l+1,l+x,&mn,&mx);
				}
				ans = max(ans , mn-l);
				l=mx;
			}
		}
		return ans;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 0 ms 336 KB Output is correct
7 Correct 0 ms 336 KB Output is correct
8 Correct 0 ms 336 KB Output is correct
9 Correct 0 ms 336 KB Output is correct
10 Correct 0 ms 336 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 10 ms 720 KB Output is correct
17 Correct 10 ms 720 KB Output is correct
18 Correct 11 ms 724 KB Output is correct
19 Correct 10 ms 720 KB Output is correct
20 Correct 8 ms 608 KB Output is correct
21 Correct 36 ms 1780 KB Output is correct
22 Correct 36 ms 1812 KB Output is correct
23 Correct 39 ms 1864 KB Output is correct
24 Correct 37 ms 1856 KB Output is correct
25 Correct 33 ms 1784 KB Output is correct
26 Correct 37 ms 1832 KB Output is correct
27 Correct 36 ms 1864 KB Output is correct
28 Correct 38 ms 1832 KB Output is correct
29 Correct 36 ms 1920 KB Output is correct
30 Correct 34 ms 1864 KB Output is correct
31 Correct 0 ms 336 KB Output is correct
32 Correct 0 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 0 ms 336 KB Output is correct
7 Correct 0 ms 336 KB Output is correct
8 Correct 0 ms 336 KB Output is correct
9 Correct 0 ms 336 KB Output is correct
10 Correct 0 ms 336 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 9 ms 476 KB Output is correct
17 Correct 6 ms 428 KB Output is correct
18 Correct 9 ms 476 KB Output is correct
19 Correct 8 ms 464 KB Output is correct
20 Correct 5 ms 484 KB Output is correct
21 Correct 24 ms 1048 KB Output is correct
22 Correct 30 ms 1080 KB Output is correct
23 Correct 26 ms 1004 KB Output is correct
24 Correct 25 ms 1064 KB Output is correct
25 Correct 49 ms 1004 KB Output is correct
26 Correct 26 ms 1052 KB Output is correct
27 Correct 28 ms 1020 KB Output is correct
28 Correct 26 ms 1096 KB Output is correct
29 Correct 27 ms 1080 KB Output is correct
30 Correct 13 ms 1060 KB Output is correct
31 Correct 0 ms 336 KB Output is correct
32 Correct 0 ms 336 KB Output is correct