답안 #563751

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
563751 2022-05-18T05:08:49 Z khangal Gap (APIO16_gap) C++14
30 / 100
46 ms 1956 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<=100){
		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 208 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 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 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 12 ms 644 KB Output is correct
17 Correct 10 ms 680 KB Output is correct
18 Correct 10 ms 720 KB Output is correct
19 Correct 10 ms 720 KB Output is correct
20 Correct 8 ms 720 KB Output is correct
21 Correct 37 ms 1864 KB Output is correct
22 Correct 35 ms 1956 KB Output is correct
23 Correct 38 ms 1832 KB Output is correct
24 Correct 38 ms 1864 KB Output is correct
25 Correct 31 ms 1832 KB Output is correct
26 Correct 37 ms 1840 KB Output is correct
27 Correct 44 ms 1892 KB Output is correct
28 Correct 40 ms 1836 KB Output is correct
29 Correct 35 ms 1812 KB Output is correct
30 Correct 29 ms 1848 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 0 ms 336 KB Output is correct
2 Partially correct 0 ms 336 KB Partially correct
3 Partially correct 1 ms 336 KB Partially correct
4 Partially correct 1 ms 336 KB Partially correct
5 Partially correct 0 ms 336 KB Partially correct
6 Partially correct 0 ms 336 KB Partially correct
7 Partially correct 0 ms 336 KB Partially correct
8 Partially correct 0 ms 336 KB Partially correct
9 Partially correct 1 ms 336 KB Partially correct
10 Partially correct 1 ms 336 KB Partially correct
11 Runtime error 1 ms 336 KB Execution failed because the return code was nonzero
12 Runtime error 1 ms 324 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 464 KB Execution failed because the return code was nonzero
17 Runtime error 7 ms 464 KB Execution failed because the return code was nonzero
18 Runtime error 8 ms 464 KB Execution failed because the return code was nonzero
19 Runtime error 7 ms 464 KB Execution failed because the return code was nonzero
20 Runtime error 3 ms 464 KB Execution failed because the return code was nonzero
21 Runtime error 23 ms 1032 KB Execution failed because the return code was nonzero
22 Runtime error 31 ms 1096 KB Execution failed because the return code was nonzero
23 Runtime error 25 ms 1060 KB Execution failed because the return code was nonzero
24 Runtime error 26 ms 1096 KB Execution failed because the return code was nonzero
25 Runtime error 46 ms 1060 KB Execution failed because the return code was nonzero
26 Runtime error 24 ms 1024 KB Execution failed because the return code was nonzero
27 Runtime error 25 ms 968 KB Execution failed because the return code was nonzero
28 Runtime error 25 ms 1060 KB Execution failed because the return code was nonzero
29 Runtime error 23 ms 1072 KB Execution failed because the return code was nonzero
30 Runtime error 18 ms 1104 KB Execution failed because the return code was nonzero
31 Correct 0 ms 336 KB Output is correct
32 Correct 0 ms 336 KB Output is correct