# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
15817 |
2015-07-30T06:08:43 Z |
joonas |
전봇대 (KOI13_pole) |
C++ |
|
44 ms |
2112 KB |
#include <cstdio>
#include <cstdlib>
#include <iostream>
typedef long long int lld;
inline lld min(lld a, lld b){return a>b?b:a;}
lld sum(int *A, int N, int d){
lld r=0;
for(int i=0; i<N; ++i) r+=std::abs((1LL)*d*i-A[i]);
return r;
}
int A[100001];
int main(){
int i, N;
scanf("%d",&N);
for(i=0;i<N;++i) scanf("%d", &A[i]);
lld L=0, R=1000000000;
while(L<=R){
lld d=(L+R)/2;
if(sum(A,N,d)<sum(A,N,d+1)) R=d-1;
else L=d+1;
}
printf("%lld\n", sum(A,N,L));
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2112 KB |
Output is correct |
2 |
Correct |
0 ms |
2112 KB |
Output is correct |
3 |
Correct |
0 ms |
2112 KB |
Output is correct |
4 |
Correct |
0 ms |
2112 KB |
Output is correct |
5 |
Correct |
0 ms |
2112 KB |
Output is correct |
6 |
Correct |
0 ms |
2112 KB |
Output is correct |
7 |
Correct |
0 ms |
2112 KB |
Output is correct |
8 |
Correct |
0 ms |
2112 KB |
Output is correct |
9 |
Correct |
0 ms |
2112 KB |
Output is correct |
10 |
Correct |
0 ms |
2112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2112 KB |
Output is correct |
2 |
Correct |
0 ms |
2112 KB |
Output is correct |
3 |
Correct |
0 ms |
2112 KB |
Output is correct |
4 |
Correct |
0 ms |
2112 KB |
Output is correct |
5 |
Correct |
0 ms |
2112 KB |
Output is correct |
6 |
Correct |
0 ms |
2112 KB |
Output is correct |
7 |
Correct |
0 ms |
2112 KB |
Output is correct |
8 |
Correct |
0 ms |
2112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2112 KB |
Output is correct |
2 |
Correct |
1 ms |
2112 KB |
Output is correct |
3 |
Correct |
5 ms |
2112 KB |
Output is correct |
4 |
Correct |
5 ms |
2112 KB |
Output is correct |
5 |
Correct |
5 ms |
2112 KB |
Output is correct |
6 |
Correct |
5 ms |
2112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
2112 KB |
Output is correct |
2 |
Correct |
44 ms |
2112 KB |
Output is correct |
3 |
Correct |
40 ms |
2112 KB |
Output is correct |
4 |
Correct |
38 ms |
2112 KB |
Output is correct |
5 |
Correct |
28 ms |
2112 KB |
Output is correct |
6 |
Correct |
22 ms |
2112 KB |
Output is correct |