답안 #563752

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
563752 2022-05-18T05:09:25 Z khangal Gap (APIO16_gap) C++14
30 / 100
43 ms 1872 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 || n<=10){
		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);
		ll 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 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 1 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 1 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 632 KB Output is correct
17 Correct 13 ms 696 KB Output is correct
18 Correct 9 ms 640 KB Output is correct
19 Correct 10 ms 720 KB Output is correct
20 Correct 8 ms 612 KB Output is correct
21 Correct 37 ms 1792 KB Output is correct
22 Correct 36 ms 1812 KB Output is correct
23 Correct 38 ms 1872 KB Output is correct
24 Correct 43 ms 1864 KB Output is correct
25 Correct 32 ms 1864 KB Output is correct
26 Correct 36 ms 1852 KB Output is correct
27 Correct 37 ms 1864 KB Output is correct
28 Correct 38 ms 1832 KB Output is correct
29 Correct 43 ms 1780 KB Output is correct
30 Correct 31 ms 1828 KB Output is correct
31 Correct 0 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Runtime error 0 ms 336 KB Execution failed because the return code was nonzero
3 Runtime error 0 ms 336 KB Execution failed because the return code was nonzero
4 Runtime error 0 ms 336 KB Execution failed because the return code was nonzero
5 Runtime error 1 ms 336 KB Execution failed because the return code was nonzero
6 Runtime error 0 ms 336 KB Execution failed because the return code was nonzero
7 Runtime error 0 ms 208 KB Execution failed because the return code was nonzero
8 Runtime error 1 ms 336 KB Execution failed because the return code was nonzero
9 Runtime error 0 ms 336 KB Execution failed because the return code was nonzero
10 Runtime error 0 ms 336 KB Execution failed because the return code was nonzero
11 Runtime error 1 ms 336 KB Execution failed because the return code was nonzero
12 Runtime error 1 ms 336 KB Execution failed because the return code was nonzero
13 Runtime error 1 ms 336 KB Execution failed because the return code was nonzero
14 Runtime error 1 ms 336 KB Execution failed because the return code was nonzero
15 Runtime error 1 ms 336 KB Execution failed because the return code was nonzero
16 Runtime error 7 ms 512 KB Execution failed because the return code was nonzero
17 Runtime error 7 ms 436 KB Execution failed because the return code was nonzero
18 Runtime error 9 ms 464 KB Execution failed because the return code was nonzero
19 Runtime error 9 ms 464 KB Execution failed because the return code was nonzero
20 Runtime error 4 ms 464 KB Execution failed because the return code was nonzero
21 Runtime error 29 ms 1004 KB Execution failed because the return code was nonzero
22 Runtime error 25 ms 1032 KB Execution failed because the return code was nonzero
23 Runtime error 23 ms 1044 KB Execution failed because the return code was nonzero
24 Runtime error 24 ms 1084 KB Execution failed because the return code was nonzero
25 Runtime error 34 ms 976 KB Execution failed because the return code was nonzero
26 Runtime error 24 ms 1060 KB Execution failed because the return code was nonzero
27 Runtime error 25 ms 980 KB Execution failed because the return code was nonzero
28 Runtime error 25 ms 1020 KB Execution failed because the return code was nonzero
29 Runtime error 32 ms 1044 KB Execution failed because the return code was nonzero
30 Runtime error 14 ms 1036 KB Execution failed because the return code was nonzero
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 336 KB Output is correct