# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
82734 |
2018-11-01T13:52:49 Z |
KLPP |
Krov (COCI17_krov) |
C++14 |
|
1500 ms |
3764 KB |
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int lld;
#define INF 100000000000000000
lld dist(lld a, lld b){
if(a<b)return b-a;
return a-b;
}
int main(){
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)cin>>arr[i];
lld ans=INF;
for(int bottom=0;bottom<n;bottom++){
lld can=0;
int b[n];
for(int i=0;i<n;i++)b[i]=arr[i]+dist(i,bottom);
sort(b,b+n);
int mid=n/2;
lld height=max(1+max(bottom,n-bottom-1),b[mid]);
for(int i=0;i<n;i++)can+=dist(height,b[i]);
ans=min(ans,can);
//cout<<can<<" "<<height<<endl;
}cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
504 KB |
Output is correct |
2 |
Correct |
63 ms |
544 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
732 KB |
Output is correct |
2 |
Correct |
60 ms |
736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
138 ms |
876 KB |
Output is correct |
2 |
Correct |
185 ms |
984 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
226 ms |
984 KB |
Output is correct |
2 |
Correct |
188 ms |
984 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
359 ms |
984 KB |
Output is correct |
2 |
Correct |
358 ms |
984 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1553 ms |
984 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1551 ms |
1268 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1568 ms |
1668 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1565 ms |
2560 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1578 ms |
3764 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |