답안 #160839

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
160839 2019-10-30T07:59:19 Z nafis_shifat Gap (APIO16_gap) C++14
100 / 100
115 ms 1912 KB
#include "gap.h"
#include<bits/stdc++.h>
#define pii pair<int,int>
#define ll long long
using namespace std;

const ll inf=1e18;
ll solve1(int N)
{
	int n=N;
	ll a[n];
	int id=0;

	ll l1=0;
	ll l2=inf;
	ll mn,mx;
	while(n>0)
	{
	    
		MinMax(l1,l2,&mn,&mx);
		if(mx!=mn)n-=2;
		else n--;
		a[id]=mn;
		a[N-id-1]=mx;
		id++;
		l1=mn+1;
		l2=mx-1;
	
	}
	ll c=0;

	for(int i=1;i<N;i++)c=max(c,a[i]-a[i-1]);
	return c;
}
ll solve2(int N)
{
	ll mx,mn;
	mx=mn=-1;

	MinMax(0,inf,&mn,&mx);


	ll sm=mn;
	ll up=mx;
	ll off=(mx-mn-1)/N;

	ll lst=sm;
	ll cur=0;

	ll pnt=sm+1;
	
	for(int i=1;i<N;i++)
	{

		MinMax(pnt,pnt+off-1,&mn,&mx);
		if(mn!=-1)
		{
			cur=max(cur,mn-lst);
			lst=mx;
		}
		pnt+=off;
	}

	MinMax(pnt,up-1,&mn,&mx);

	if(mn!=-1)
	{
		cur=max(cur,mn-lst);
		cur=max(cur,up-mx);
	}
	else
	{
		cur=max(cur,up-lst);
	}


	return cur;





}
long long findGap(int T, int N)
{
	if(T==1)return solve1(N);
	return solve2(N);

}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 15 ms 764 KB Output is correct
17 Correct 16 ms 760 KB Output is correct
18 Correct 15 ms 760 KB Output is correct
19 Correct 15 ms 760 KB Output is correct
20 Correct 11 ms 760 KB Output is correct
21 Correct 55 ms 1912 KB Output is correct
22 Correct 107 ms 1912 KB Output is correct
23 Correct 56 ms 1912 KB Output is correct
24 Correct 115 ms 1912 KB Output is correct
25 Correct 47 ms 1912 KB Output is correct
26 Correct 56 ms 1912 KB Output is correct
27 Correct 56 ms 1912 KB Output is correct
28 Correct 55 ms 1912 KB Output is correct
29 Correct 56 ms 1912 KB Output is correct
30 Correct 43 ms 1912 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 13 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 35 ms 504 KB Output is correct
17 Correct 19 ms 504 KB Output is correct
18 Correct 19 ms 504 KB Output is correct
19 Correct 19 ms 504 KB Output is correct
20 Correct 9 ms 504 KB Output is correct
21 Correct 75 ms 1144 KB Output is correct
22 Correct 77 ms 1144 KB Output is correct
23 Correct 91 ms 1272 KB Output is correct
24 Correct 73 ms 1144 KB Output is correct
25 Correct 71 ms 1144 KB Output is correct
26 Correct 74 ms 1144 KB Output is correct
27 Correct 73 ms 1144 KB Output is correct
28 Correct 74 ms 1272 KB Output is correct
29 Correct 88 ms 1108 KB Output is correct
30 Correct 39 ms 1144 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct