답안 #15820

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
15820 2015-07-30T10:22:34 Z ggoh 전봇대 (KOI13_pole) C++
100 / 100
46 ms 1864 KB
#include<cstdio>
#include<algorithm>
long long i,x[100005],a,m,M,p,q,h;
long long abs(long long z, long long w){return z>w?z-w:w-z;}
long long f(long long t)
{
	m=0;
	for(i=0;i<a;i++)
	{
		m+=abs(x[i],i*t);
	}
	return m;
}
main()
{
	scanf("%lld",&a);
	for(i=0;i<a;i++)scanf("%lld",&x[i]);
	p=0;q=1e9;
	while(p!=q-1)
	{
		h=(p+q)/2;
		if(f(h)<f(h+1))q=h;
		else p=h;
	}
	printf("%lld",std::min(f(p),f(q)));
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1864 KB Output is correct
2 Correct 0 ms 1864 KB Output is correct
3 Correct 0 ms 1864 KB Output is correct
4 Correct 0 ms 1864 KB Output is correct
5 Correct 0 ms 1864 KB Output is correct
6 Correct 0 ms 1864 KB Output is correct
7 Correct 0 ms 1864 KB Output is correct
8 Correct 0 ms 1864 KB Output is correct
9 Correct 0 ms 1864 KB Output is correct
10 Correct 0 ms 1864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1864 KB Output is correct
2 Correct 0 ms 1864 KB Output is correct
3 Correct 0 ms 1864 KB Output is correct
4 Correct 0 ms 1864 KB Output is correct
5 Correct 0 ms 1864 KB Output is correct
6 Correct 0 ms 1864 KB Output is correct
7 Correct 0 ms 1864 KB Output is correct
8 Correct 0 ms 1864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1864 KB Output is correct
2 Correct 0 ms 1864 KB Output is correct
3 Correct 0 ms 1864 KB Output is correct
4 Correct 4 ms 1864 KB Output is correct
5 Correct 0 ms 1864 KB Output is correct
6 Correct 0 ms 1864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 1864 KB Output is correct
2 Correct 32 ms 1864 KB Output is correct
3 Correct 38 ms 1864 KB Output is correct
4 Correct 37 ms 1864 KB Output is correct
5 Correct 36 ms 1864 KB Output is correct
6 Correct 46 ms 1864 KB Output is correct