답안 #12955

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
12955 2015-01-21T12:37:35 Z gs13068 구경하기 (JOI13_watching) C++
100 / 100
52 ms 16780 KB
#include<cstdio>
#include<algorithm>

long long c[2002];
int x[2002];
int y[2002];
int d[2002][2002];

int main()
{
	int l,r,mid;
	int i,j,k,n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	if(a+b>=n)
	{
		puts("1");
		return 0;
	}
	for(i=1;i<=n;i++)scanf("%lld",&c[i]);
	std::sort(c+1,c+n+1);
	l=1;
	r=(1e9+a+b+b-1)/(a+b+b);
	for(i=0;i<=n&&i<=a;i++)for(j=0;i+j<=n&&j<=b;j++)d[i][j]=1;
	while(l<r)
	{
		mid=(l+r)/2;
        for(i=1;i<=n;i++)
		{
			x[i]=std::lower_bound(c+i+1,c+n+1,c[i]+mid)-c;
			y[i]=std::lower_bound(c+i+1,c+n+1,c[i]+mid+mid)-c;
		}
		x[n+1]=y[n+1]=n+1;
		for(i=0;i<=n&&i<=a;i++)
		{
			for(j=0;i+j<=n&&j<=b;j++)
			{
                d[i][j]=1;
                if(j>0&&y[d[i][j-1]]>d[i][j])d[i][j]=y[d[i][j-1]];
                if(i>0&&x[d[i-1][j]]>d[i][j])d[i][j]=x[d[i-1][j]];
                if(d[i][j]>n)break;
			}
			if(i+j<=n&&j<=b)break;
		}
        if(i<=n&&i<=a)r=mid;
        else l=mid+1;
	}
	printf("%d",l);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 16780 KB Output is correct
2 Correct 0 ms 16780 KB Output is correct
3 Correct 0 ms 16780 KB Output is correct
4 Correct 0 ms 16780 KB Output is correct
5 Correct 0 ms 16780 KB Output is correct
6 Correct 0 ms 16780 KB Output is correct
7 Correct 0 ms 16780 KB Output is correct
8 Correct 0 ms 16780 KB Output is correct
9 Correct 0 ms 16780 KB Output is correct
10 Correct 0 ms 16780 KB Output is correct
11 Correct 0 ms 16780 KB Output is correct
12 Correct 0 ms 16780 KB Output is correct
13 Correct 0 ms 16780 KB Output is correct
14 Correct 0 ms 16780 KB Output is correct
15 Correct 0 ms 16780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 16780 KB Output is correct
2 Correct 0 ms 16780 KB Output is correct
3 Correct 0 ms 16780 KB Output is correct
4 Correct 0 ms 16780 KB Output is correct
5 Correct 0 ms 16780 KB Output is correct
6 Correct 0 ms 16780 KB Output is correct
7 Correct 4 ms 16780 KB Output is correct
8 Correct 8 ms 16780 KB Output is correct
9 Correct 12 ms 16780 KB Output is correct
10 Correct 12 ms 16780 KB Output is correct
11 Correct 4 ms 16780 KB Output is correct
12 Correct 52 ms 16780 KB Output is correct
13 Correct 4 ms 16780 KB Output is correct
14 Correct 4 ms 16780 KB Output is correct
15 Correct 0 ms 16780 KB Output is correct