#include<iostream>
#include<vector>
#include<numeric>
#include<algorithm>
using namespace std;
int main(){
int n;
cin >> n;
vector<int> v(n);
for (int i = 0; i < n;++i){
cin >> v[i];
}
sort(v.begin(), v.end());
int p = n / 2;
if(n&1){
int a = accumulate(v.begin() + p, v.end(), 0) - accumulate(v.begin(), v.begin() + p, 0);
int b = accumulate(v.begin() + p+1, v.end(), 0) - accumulate(v.begin(), v.begin() + p+1, 0);
if(a>b){
cout << "Outgoing #: " << p+1 << "\n";
cout << "Introverted #: " << p << "\n";
cout << "Diff = " <<a<<"\n";
}else{
cout << "Outgoing #: " << p << "\n";
cout << "Introverted #: " << p+1 << "\n";
cout << "Diff = " <<b<<"\n";
}
}else{
cout << "Outgoing #: " << p << "\n";
cout << "Introverted #: " << p << "\n";
cout << "Diff = " <<accumulate(v.begin()+p,v.end(),0)-accumulate(v.begin(), v.begin() + p, 0)<<"\n";
}
}
L2-017 人以群分 (25 分)
最新推荐文章于 2024-06-12 22:21:32 发布