链接: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. 同程联盟景点门票动态程序 beta1.0源码

    经过一段时间的开发,以及内部测试,同程网联盟景区新版程序正式发布推出,感谢广大联盟会员一直以来的支持与关注! 同程网联盟景区新版程序新功能介绍: 1.统一的页面风格.页面风格将与随后推出的度假线路.酒 ...

  2. BZOJ 3314 [Usaco2013 Nov]Crowded Cows:单调队列

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=3314 题意: N头牛在一个坐标轴上,每头牛有个高度.现给出一个距离值D. 如果某头牛在它的 ...

  3. 分享知识-快乐自己:微服务的注册与发现(基于Eureka)

    1):微服务架构 服务提供者.服务消费者.服务发现组件这三者之间的关系: 各个微服务在启动时,将自己的网络地址等信息注册到服务发现组件中,服务发现组件会存储这些信息. 服务消费者可从服务发现组件查询服 ...

  4. tomcat 6.0 安装及配置

    前提:安装并配置好jdk 1.免安装版存放目录:D:\01Install\tomcat

  5. linux命令学习:echo详解,格式化输出,不换行输出

    shell脚本不换行刷新数据 #!/bin/bash ] do a=$(ifconfig eth0 | grep 'RX pac' | awk '{print $2}' | awk -F: '{pri ...

  6. Codeforces Round #397 题解

    Problem A. Neverending competitions 题目大意 一个团队有多个比赛,每次去比赛都会先订机票去比赛地点,然后再订机票返回.给出\(n\)个含有起止地点的购票记录(不按时 ...

  7. bzoj 3872 [Poi2014]Ant colony——二分答案

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3872 可以倒推出每个叶子节点可以接受的值域.然后每个叶子二分有多少个区间符合即可. 注意一开 ...

  8. Tomcat加载servlet类文件

    问题1:tomcat什么时候加载servlet? 有两种情况 一种是启动时加载 一种是请求时加载 第一种是在web.xml中的<servlet>节点下增加类似:<load-on-st ...

  9. PowerShell自动部署网站—(2)、安装.Net Framework

    #$PSScriptRoot = "D:\Website":$PSScriptRoot 用于获取执行脚本所在的目录,但是PowerShell 2.0 不支持,需要人为赋值成绝对路径 ...

  10. undefined reference to `pthread_create' collect2: ld returned 1 exit status

    问题原因:    pthread 库不是 Linux 系统默认的库,连接时需要使用静态库 libpthread.a,所以在使用pthread_create()创建线程,以及调用 pthread_atf ...