2021-12-09 06:11:44 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
vector<int> crabs(1000);
|
|
|
|
|
|
|
|
for(int i = 0; i < 1000; i++) cin >> crabs[i];
|
|
|
|
|
|
|
|
sort(crabs.begin(), crabs.end());
|
|
|
|
|
|
|
|
vector<int> costs(crabs[999],0);
|
|
|
|
|
|
|
|
for(int i = 0; i < costs.size(); i++)
|
|
|
|
{
|
|
|
|
for(int j = 0; j < 1000; j++)
|
|
|
|
{
|
|
|
|
int diff = (int)abs((float)i-crabs[j]);
|
|
|
|
costs[i] += (diff*(diff+1))/2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sort(costs.begin(), costs.end());
|
|
|
|
|
|
|
|
cout << costs[0] << endl;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|