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 ...
随机推荐
- 【Machine Learning in Action --4】朴素贝叶斯分类
1.概述 朴素贝叶斯分类是贝叶斯分类器的一种,贝叶斯分类算法是统计学的一种分类方法,利用概率统计知识进行分类,其分类原理就是利用贝叶斯公式根据某对象的先验 概率计算出其后验概率(即该对象属于某一类的概 ...
- js整频滚动展示效果(函数节流鼠标滚轮事件)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- C#采用OpenXml给word里面插入图片
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threa ...
- POJ 3279 Fliptile[二进制状压DP]
题目链接[http://poj.org/problem?id=3279] 题意:给出一个大小为M*N(1 ≤ M ≤ 15; 1 ≤ N ≤ 15) 的图,图中每个格子代表一个灯泡,mp[i][j] ...
- (译)UEFI 启动:实际工作原理
本文是我翻译自国外技术博客的一篇文章,其中讲述了 UEFI 的一些基本概念和细节. 本文的原始链接位于: https://www.happyassassin.net/2014/01/25/uefi-b ...
- NOIP2014提高组第二题联合权值
还是先看题吧: 试题描述 无向连通图 G 有 n 个点,n-1 条边.点从 1 到 n 依次编号,编号为 i 的点的权值为 Wi ,每条边的长度均为 1.图上两点(u, v)的距离定义为 u 点到 ...
- js循环POST提交添加辅助单位
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- j2ee网站项目首页如何直接使用action
之前做过一些网站项目,大多数都是首页就是登录,直接进入首页的不多,也就没有注意到,今天刚好注意到了就来记一下.也算是一个小技巧 <welcome-file>index.jsp</we ...
- jQuery的dataTables插件实现中文排序
最近在写Java web. 写JSP的时候发现一个很好玩的插件dataTables.分页.过滤.排序等等手到擒来. 哎哎哎,有点点可惜的是排序这个功能不支持中文.于是网上查查找找,现在把方法整理一下, ...
- js 学习总结
new array()[] []表示数组new object(){} {}表示对象 JavaScript 对象 对象由花括号分隔.在括号内部,对象的属性以名称和值对的形式 (name : value) ...