# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
16229 |
2015-08-18T10:22:38 Z |
eaststar |
전봇대 (KOI13_pole) |
C++14 |
|
32 ms |
1472 KB |
#include <stdio.h>
#include <stdlib.h>
int a[100010],n;
long long f(int x){
long long i,s=0;
for(i=1;i<n;++i)s+=llabs(i*x-a[i]);
return s;
}
int main(){
int i,l=1,r,m;
long long ans;
scanf("%d",&n);
for(i=0;i<n;++i)scanf("%d",a+i);
r=1e9/n;
while(l<=r){
m=(l+r)/2;
ans=f(m);
if(f(m-1)<ans)r=m-1;
else if(f(m+1)<ans)l=m+1;
else break;
}
printf("%lld",ans);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1472 KB |
Output is correct |
2 |
Correct |
0 ms |
1472 KB |
Output is correct |
3 |
Correct |
0 ms |
1472 KB |
Output is correct |
4 |
Correct |
0 ms |
1472 KB |
Output is correct |
5 |
Correct |
0 ms |
1472 KB |
Output is correct |
6 |
Correct |
0 ms |
1472 KB |
Output is correct |
7 |
Correct |
0 ms |
1472 KB |
Output is correct |
8 |
Correct |
0 ms |
1472 KB |
Output is correct |
9 |
Correct |
0 ms |
1472 KB |
Output is correct |
10 |
Correct |
0 ms |
1472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1472 KB |
Output is correct |
2 |
Correct |
0 ms |
1472 KB |
Output is correct |
3 |
Correct |
0 ms |
1472 KB |
Output is correct |
4 |
Correct |
0 ms |
1472 KB |
Output is correct |
5 |
Correct |
0 ms |
1472 KB |
Output is correct |
6 |
Correct |
0 ms |
1472 KB |
Output is correct |
7 |
Correct |
0 ms |
1472 KB |
Output is correct |
8 |
Correct |
0 ms |
1472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1472 KB |
Output is correct |
2 |
Correct |
0 ms |
1472 KB |
Output is correct |
3 |
Correct |
0 ms |
1472 KB |
Output is correct |
4 |
Correct |
0 ms |
1472 KB |
Output is correct |
5 |
Correct |
3 ms |
1472 KB |
Output is correct |
6 |
Correct |
0 ms |
1472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
1472 KB |
Output is correct |
2 |
Correct |
32 ms |
1472 KB |
Output is correct |
3 |
Correct |
31 ms |
1472 KB |
Output is correct |
4 |
Correct |
24 ms |
1472 KB |
Output is correct |
5 |
Correct |
20 ms |
1472 KB |
Output is correct |
6 |
Correct |
30 ms |
1472 KB |
Output is correct |