7-27 人以群分

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
long long  n,a[100005],x,y,b[100005],dif;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
	b[i]=b[i-1]+a[i];
	if(n%2)
	{
		int pos=n/2+1;
		x=pos;y=n-pos;
		dif=b[n]-b[y]*2;
	 } 
	 else{
	 	x=y=n/2;
	 	dif=b[n]-b[n/2]*2;
	 }
	 cout<<"Outgoing #: "<<x<<endl;
	 cout<<"Introverted #: "<<y<<endl;
	 cout<<"Diff = "<<dif;
	 return 0;
}
上一篇:是真“开发者”,就来一“测”到底!


下一篇:解决mysql Table ‘xxx’ is marked as crashed and should be repaired的问题。