Submission #82734

#TimeUsernameProblemLanguageResultExecution timeMemory
82734KLPPKrov (COCI17_krov)C++14
70 / 140
1578 ms3764 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...