链接:https://codeforces.com/contest/1174/problem/A

题意:

You're given an array aa of length 2n2n. Is it possible to reorder it in such way so that the sum of the first nn elements isn't equal to the sum of the last nn elements?

思路:

排序后求前一半和后一半的和比较。

代码:

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
const int MAXN = 3e5 + 10;
const int MOD = 1e9 + 7;
int n, m, k, t; int a[2010]; int main()
{
cin >> n;
for (int i = 1;i <= 2*n;i++)
cin >> a[i];
sort(a+1, a+1+2*n);
if (accumulate(a+1, a+1+n, 0) == accumulate(a+n+1, a+1+2*n, 0))
cout << -1 << endl;
else
{
for (int i = 1; i <= 2 * n; i++)
cout << a[i] << ' ';
cout << endl;
} return 0;
}

  

Codeforces Round #563 (Div. 2) A. Ehab Fails to Be Thanos的更多相关文章

  1. Codeforces Round #563 (Div. 2) C. Ehab and a Special Coloring Problem

    链接:https://codeforces.com/contest/1174/problem/C 题意: You're given an integer nn. For every integer i ...

  2. Codeforces Round #563 (Div. 2) B. Ehab Is an Odd Person

    链接:https://codeforces.com/contest/1174/problem/B 题意: You're given an array aa of length nn. You can ...

  3. Codeforces Round #563 (Div. 2) E. Ehab and the Expected GCD Problem

    https://codeforces.com/contest/1174/problem/E dp 好题 *(if 满足条件) 满足条件 *1 不满足条件 *0 ///这代码虽然写着方便,但是常数有点大 ...

  4. Codeforces Round #563 (Div. 2) F. Ehab and the Big Finale

    后续: 点分治标程 使用father数组 比使用vis数组优秀(不需要对vis初始化) https://codeforces.com/problemset/problem/1174/F https:/ ...

  5. Codeforces Round #563 (Div. 2)/CF1174

    Codeforces Round #563 (Div. 2)/CF1174 CF1174A Ehab Fails to Be Thanos 其实就是要\(\sum\limits_{i=1}^n a_i ...

  6. Codeforces Round #563 (Div. 2)A

    A. Ehab Fails to Be Thanos 题目链接:http://codeforces.com/contest/1174/problem/A 题目 You’re given an arra ...

  7. Codeforces Round #563 (Div. 2) A-D

    A. Ehab Fails to Be Thanos 这个A题很简单,就是排个序,然后看前面n个数和后面的n个数是不是相同,相同就输出-1 #include <cstdio> #inclu ...

  8. Codeforces Round #525 (Div. 2) F. Ehab and a weird weight formula

    F. Ehab and a weird weight formula 题目链接:https://codeforces.com/contest/1088/problem/F 题意: 给出一颗点有权值的树 ...

  9. Codeforces Round #525 (Div. 2)E. Ehab and a component choosing problem

    E. Ehab and a component choosing problem 题目链接:https://codeforces.com/contest/1088/problem/E 题意: 给出一个 ...

随机推荐

  1. L92

    The Difference between Honesty and Cheating We sign our names to various documents all the time. Som ...

  2. 数据可视化入门之show me the numbers

           数据的可视化一直是自己瞎玩着学,近来想系统的学数据可视化的东西,于是搜索资料时看到有人推荐<show me the numbers>作为入门. 由于搜不到具体的书籍内容,只能 ...

  3. BJOI2018爆零记

    没啥可说的 Day1 0分 T1 给你一个二进制串,每次修改一个位置,询问[l,r]区间中有多少二进制子串重排后能被3整除 T2 一个无向图(无重边自环)每个点有一个包含两种颜色的染色集合,一个边的两 ...

  4. PHP函数---$_Get()和$_Post()的用法

    一.$_Get()和$_Post()函数是用来传值的,即对应两种提交表单的方法,get和post. 二.$_Get方法 (1)获取通过URL的传值 Example 1 新建两个PHP文件,1.php, ...

  5. request.getSession()方法的应用

    request.getSession(true):若存在会话则返回该会话,否则新建一个会话. request.getSession(false):若存在会话则返回该会话,否则返回NULL

  6. ubuntu 修改资源镜像

    要修改的文件 /etc/apt/sources.list 原资源镜像文件 deb http://mirrors.aliyun.com/ubuntu/ yakkety main multiverse r ...

  7. 项目清理和删除svn信息(转)

    svn信息是根据文件夹里面的 .svn 文件夹保存相关配置的,删除此文件夹即可去掉svn信息: linux下: find . -type d -name ".svn"|xargs ...

  8. [hdu2544]最短路spfa

    解题关键:最短路模板一直没整理过,这里整理了一下spfa+链式前向星建图的最短路模板,以后网络赛省的打了. spfa算法的关键就是松弛操作,只有进行松弛操作,其后的点距离才可能被更新. #includ ...

  9. 《精通Spring4.X企业应用开发实战》读后感第三章

  10. ubuntu12.04+virtualbox+winxp的关于摄像头无法使用,声音出不来的问题

    前天在ubuntu上安装了个virtualbox的虚拟机.以前在windows下面是用的vmware.结果到了ubuntu下面折腾半天用不了,于是就装了个virtualbox,在virtualbox里 ...