https://www.acwing.com/problem/content/1605/
1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 typedef long long LL; 5 const int N=1e5+10; 6 LL a[N]; 7 int main(void){ 8 int n; 9 cin>>n; 10 for(int i=0;i<n;i++){ 11 cin>>a[i]; 12 } 13 sort(a,a+n); 14 int sum1=0,sum2=0; 15 for(int i=0;i<n/2;i++){ 16 sum1+=a[i]; 17 } 18 for(int i=n/2;i<n;i++){ 19 sum2+=a[i]; 20 } 21 cout<<n%2<<" "<<sum2-sum1; 22 return 0; 23 }