PAT (Advanced Level) 1113. Integer Set Partition (25)

Posted Fighting Heart

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PAT (Advanced Level) 1113. Integer Set Partition (25)相关的知识,希望对你有一定的参考价值。

简单题。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;

long long a[100000+10];
long long sum=0,sum2;
int n;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        sum=sum+a[i];
    }
    sort(a+1,a+1+n);
    for(int i=1;i<=n/2;i=i+1)  sum2=sum2+a[i];
    if(n%2==0) printf("0 %lld\n",abs(2*sum2-sum));
    else printf("1 %lld\n",abs(2*sum2-sum));
    return 0;
}

 

以上是关于PAT (Advanced Level) 1113. Integer Set Partition (25)的主要内容,如果未能解决你的问题,请参考以下文章

PAT (Advanced Level) 1025. PAT Ranking (25)

PAT Advanced Level 1044

PAT Advanced Level 1043

PAT Advanced Level 1079

PAT Advanced Level 1095

PAT Advanced Level 1038