- 输油管道问题
- 2017-11-21 13:03:43 @
#include<iostream>
#include<algorithm>
using namespace std;
int a[10000], b[10000];
int main()
{ int l = 0;
int n;
cin >> n;
for (int i =1; i <= n; i++)
{
cin >> a[i] >> b[i];
}
sort(b+1, b + n);
int x = b[(n / 2) + 1];
for (int i = 1; i <= n / 2; i++)
{
l += (x - b[i]);
}
for (int i = (n / 2)+2; i <= n; i++)
{
l += (b[i] - x);
}
cout << l;
}
0 条评论
目前还没有评论...