This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;
int N;
lld B, C, D, L[100005];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
cin >> N;
for (int i = 0; i < N; i++)
cin >> L[i];
lld D = L[N-1]/(N-1);
for (int i = 0; i < N; i++) {
C += abs(L[i] - D*i);
}
D++;
for (int i = 0; i < N; i++) {
B += abs(L[i] - D*i);
}
cout << min(B, C);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |