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());
|
|
|
|
|
|
|
|
int final_position = round(((float)crabs[499]+(float)crabs[500])/2.0f);
|
|
|
|
|
|
|
|
int fuel = 0;
|
|
|
|
for(int i = 0; i < 1000; i++) fuel += (int)abs((float)final_position-crabs[i]);
|
|
|
|
|
|
|
|
cout << fuel << endl;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|