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;
int main()
{
int n, k;
cin >> n >> k;
int M[n];
long long suma = 0;
for(int i = 0; i<n; i++)
{
cin >> M[i];
suma += M[i];
}
double liekana = suma%n;
suma /= n;
liekana /= n;
liekana = round(liekana);
int vidurkis = suma+liekana;
sort(M, M+n);
vidurkis = M[n/2];
//cout << vidurkis << endl;
long long ats = 0;
for(int i = 0; i<n; i++)
{
ats += abs(M[i] - vidurkis);
//cout << ats << ' ';
}
cout << ats;
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... |
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |