其他分享
首页 > 其他分享> > 7-27 人以群分

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;
}

标签:27,int,dif,人以群分,long,pos,100005,include
来源: https://blog.csdn.net/gyp0205/article/details/122278682