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 ...
随机推荐
- Yii2.0的安装与配置教程
版权声明:本文为博主原创文章,未经博主允许不得转载. PHP版本需求:PHP5.4.0以上,因为Yii2.0基于PHP5.4以上版本进行了完全重写. 目前有两种方法可以安装Yii2.0,一种是安装Co ...
- wordpress建站过程3——header.php
header.php中包含了一个页面的页头,也就是其他页面中重复出现的部分,包括用户登陆/登陆后显示的文字,导航条,网页logo,有的还包括轮播图. 下面就简单的贴上一个文件吧. <!DOCTY ...
- POJ 2516 Minimum Cost
每个物品分开做最小费用最大流. #include<cstdio> #include<cstring> #include<cmath> #include<vec ...
- 用VS2012或VS2013在win7下编写的程序在XP下运行就出现“不是有效的win32应用程序
经常创建项目的时候,采用空项目,那么编译成功后,最好修改下sbusystem . 链接器->系统->子系统->控制台或windows 后面的"最低版本"是5.01
- 《JS权威指南学习总结--1.2客户端JS》
1.2客户端JS --本节讲述客户端JS部分各章节的讲述内容 一.第十三章讲述JS代码通过<script>标签来嵌入到HTML文件中. 二.第十四章讲解WEB浏览器脚本技术,并涵盖客户端J ...
- js 插入图片切换,innerHTML
<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content=&q ...
- 在C#中使用反射调用internal的方法
MSDN上解释Internal如下: The internal keyword is an access modifier for types and type members. Internal t ...
- 最近客户的apache+php环境运行很慢解决
描述:[Wed Jul 24 15:49:11 2013] [warn] (OS 64)指定的网络名不再可用. : winnt_accept: Asynchronous AcceptEx faile ...
- 初识golang
golang是一门编译型的语言. 问题1:int和*int有啥区别?和c语言中有区别么? var a int = 32 var b *int = &a fmt.Println("ty ...
- 数据库连接池c3p0的设置
spring-hibernate.xml配置 <?xml version="1.0" encoding="UTF-8"?> <beans xm ...