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[+];
long long sum=,sum2;
int n; int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%lld",&a[i]);
sum=sum+a[i];
}
sort(a+,a++n);
for(int i=;i<=n/;i=i+) sum2=sum2+a[i];
if(n%==) printf("0 %lld\n",abs(*sum2-sum));
else printf("1 %lld\n",abs(*sum2-sum));
return ;
}
PAT (Advanced Level) 1113. Integer Set Partition (25)的更多相关文章
- 【PAT甲级】1113 Integer Set Partition (25分)
题意: 输入一个正整数N(2<=N<=1e5),接着输入N个正整数,将这些数字划分为两个不相交的集合,使得他们的元素个数差绝对值最小且元素和差绝对值最大. AAAAAccepted cod ...
- 1113. Integer Set Partition (25)
Given a set of N (> 1) positive integers, you are supposed to partition them into two disjoint se ...
- PAT (Advanced Level) 1007. Maximum Subsequence Sum (25) 经典题
Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to be { Ni, ...
- PAT (Advanced Level) Practice 1028 List Sorting (25 分) (自定义排序)
Excel can sort records according to any column. Now you are supposed to imitate this function. Input ...
- PAT (Advanced Level) Practice 1003 Emergency 分数 25 迪杰斯特拉算法(dijkstra)
As an emergency rescue team leader of a city, you are given a special map of your country. The map s ...
- PAT (Advanced Level) 1110. Complete Binary Tree (25)
判断一棵二叉树是否完全二叉树. #include<cstdio> #include<cstring> #include<cmath> #include<vec ...
- PAT (Advanced Level) 1103. Integer Factorization (30)
暴力搜索. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...
- PAT (Advanced Level) 1094. The Largest Generation (25)
简单DFS. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> ...
- PAT (Advanced Level) 1074. Reversing Linked List (25)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...
随机推荐
- MySql 安装报错 :Last Error:Unable to update security. Access denied for user 'root'@'localhost(useing password:YES)
在网上查了一下,其实这个问题很好解决,. try again 然后current password mysql是默认密码为空,不要填,记住不要填就ok了
- GRPC: set up..
get the grpc source file.. git clone https://github.com/grpc/grpc git submodule update --init --recu ...
- Windows命令查看文件MD5码
D:\>certutil -hashfile md5test.txt MD5 MD5 哈希(文件 md5test.txt): d6 f6 bb 38 b5 6b 67 8f 34 9b e4 d ...
- Ubuntu上用mod_wsgi部署Django出现的一些问题
1 编码问题 直接运行Django没问题,但通过Apache+mod_wsgi上传中文字符的文件时出错: UnicodeEncodeError: 'ascii' codec can't encode ...
- 观看网上的N多教程有感
MD只想说一句,我擦. 长篇大论,有个叼毛用呀,显示你文采.... 糟粕真TMD多,直接简单的步骤多好,不要显示的你有多专业,其实就是一个二逼. 还有N多论坛,扯淡的人更多.
- Chapter 1 First Sight——26
"Which ones are the Cullens?" I asked. "They don't look related…" 哪一个是卡伦,我问道,他们都 ...
- LeetCode OJ 220.Contains Duplicate 3
Given an array of integers, find out whether there are two distinct indices i and j in the array suc ...
- nefu 72 N!
Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N! Input One N in one line, ...
- 聊一聊PV和并发、以及计算web服务器的数量的方法【转】
聊一聊PV和并发.以及计算web服务器的数量的方法 站长之家 2016-08-17 09:40 最近和几个朋友,聊到并发和服务器的压力问题.很多朋友,不知道该怎么去计算并发?部署多少台服务器才合适? ...
- PMBok项目管理
这就是项目管理的九大领域:整合管理.范围管理.时间管理.费用管理.质量管理.人力资源管理.沟通管理.风险管理.采购管理. 项目管理好像一头大象,将其大卸九块之后,要装进冰箱就容易多了. 看看书上是怎样 ...