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 <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
long long N, x[100001], y[100001], Ans;
void input(void)
{
long long i;
scanf("%lld %lld",&N,&i);
for(i=1 ; i<N ; i++)
{
scanf("%lld",&x[i]);
y[i]=x[i]/i;
}
sort(y+1,y+N);
}
void process(void)
{
long long i, temp=0;
for(i=1 ; i<N ; i++)
{
Ans+=abs(x[i]-i*y[N/2]);
temp+=abs(x[i]-i*(y[N/2]+1));
}
if(Ans>temp)
Ans=temp;
}
void output(void)
{
printf("%lld",Ans);
}
int main(void)
{
input();
process();
output();
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... |