按照题目意思,排个序就好
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e5 + 5;
int arr[N];
int main () {
int n;
cin >> n;
for (int i = 0;i < n;i++) cin >> arr[i];
sort(arr,arr + n);
int mid = n / 2;
if (n % 2 == 0) {
int ans = 0;
for (int i = 0;i < mid;i++) {
ans += arr[mid + i] - arr[i];
}
cout << 0 << ' ' << ans << endl;
} else {
int s1 = 0,s2 = 0,ans;
for (int i = 0;i < mid;i++) {
s1 += arr[i];
s2 += arr[mid + i + 1];
}
ans = max(abs(s1 + arr[mid] - s2),abs(s2 + arr[mid] - s1));
cout << 1 << ' ' << ans << endl;
}
return 0;
}