题目
思路
。。弱智题
代码
#include <iostream>
#include <vector>
using namespace std;
vector<int> vec;
int main()
{
int n;
cin >> n;
vec.resize(n);
for (int i = 0; i < n; ++i) cin>>vec[i];
sort(vec.begin(), vec.end());
int num, sum;
int k = n / 2;
if (n % 2 == 0)
num = 0;
else
num = 1;
int sum1 = 0, sum2 = 0;
for (int i = 0; i < k; ++i)
sum1 += vec[i];
for (int i = k; i < n; ++i)
sum2 += vec[i];
sum = abs(sum1 - sum2);
cout << num << " " << sum;
}