链接: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;
}

  

转载于:https://www.cnblogs.com/YDDDD/p/10972855.html

Codeforces Round #563 (Div. 2) A. Ehab Fails to Be Thanos相关推荐

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

    地址:https://codeforces.com/contest/1174/problem/F 思路:思维+分治 官方题解:https://codeforces.com/blog/entry/673 ...

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

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

  3. 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 ...

  4. Codeforces Round #628 (Div. 2) F. Ehab‘s Last Theorem dfs树

    传送门 文章目录 题意: 思路: 题意: 给你个nnn个点mmm条边的图,可以选择完成以下两个任务中的一个: (1)(1)(1)找出大小恰好为n\sqrt nn​的一个独立集. (2)(2)(2)找出 ...

  5. Codeforces Round #628 (Div. 2) E. Ehab‘s REAL Number Theory Problem 巧妙的质因子建图

    传送门 文章目录 题意: 思路: 题意: 给你nnn个数,每个数的因子个数不超过777个,选出最少的数使其乘积为平方数. n≤1e5n\le 1e5n≤1e5 思路: 由于因子不超过777个,所以由约 ...

  6. Codeforces Round #649 (Div. 2)C. Ehab and Prefix MEXs[排列的构造]

    C. Ehab and Prefix MEXs 题目大意: 解题思路:题目说保证a数组是非递减的,那么如果某位置a[i]!=a[i−1]a[i]!=a[i-1]a[i]!=a[i−1]那么这个位置ii ...

  7. Codeforces Round #628 (Div. 2)C - Ehab and Path-etic MEXs

    C - Ehab and Path-etic MEXs 题目链接 简要描述: 从一个点到另一个点出发,所经过的边组成一个集合, 这些集合中所不包含的最小自然数为mex(u,v),要求使所有的mex(u ...

  8. Codeforces Round #628 (Div. 2) C. Ehab and Path-etic MEXs

    C. Ehab and Path-etic MEXs 题目链接-C. Ehab and Path-etic MEXs Note The tree from the second sample: 题目大 ...

  9. Codeforces Round #628 (Div. 2) D. Ehab the Xorcist

    D. Ehab the Xorcist 题目链接-D. Ehab the Xorcist 题目大意 给定两个数字 u 和 v ,构造一个最短的序列a满足a1⊕a2⊕-⊕an=u 并且 a1+a2+-+ ...

  10. 【Codeforces Round #525(Div. 2)】Ehab and another another xor problem(思维+异或)

    题目链接 D. Ehab and another another xor problem time limit per test 1 second memory limit per test 256 ...

最新文章

  1. Facebook性能大提升的秘密:HipHop
  2. qmake 简易教程
  3. Nginx-09:Nginx原理
  4. 跟着老王学python
  5. 我把序列化玩成了这样,吊锤了一波面试官
  6. 关于WebApi 跨域问题的解决的方式
  7. Java笔记-使用RabbitMQ的Java接口实现Publish/Subscribe(订阅模式)
  8. 获得驱动器信息卷设备Ring3得到磁盘文件系统(NTFS WIN10)
  9. TFS首次安装与配置,极其注意事项个人备用
  10. Hive常见函数大全
  11. 口腔取模过程及注意事项_为什么牙齿矫正前要拍片取模,没有拍片取模就设计不了详细方案!...
  12. 二叉树中和为某一值的路径(三)(C++)
  13. 编译Windows版本ffmpeg:msys2方式失败
  14. java c 引用类型_C++引用类型详解
  15. GM300单片硅钢铁损测试仪操作使用指引
  16. ImageIO 先read再write 文件变小了
  17. 陈莉君: Linux内核的那些书
  18. java基础之后台线程_繁星漫天_新浪博客
  19. LSP是第一生产力 深夜开车,图片不够了怎么办?爪巴就完事了(爬虫爬取网页图片)
  20. 计算机网络实验(思科)

热门文章

  1. Bash : 冒泡排序
  2. Centos7配置ThinkPHP5.0完整过程(二)
  3. OSG-基本几何图形
  4. Python自动化之socket初识
  5. 第九天 面试失败了。。。。
  6. CPU acceleration status:HAXM must be updated(version 1.1.16.0.1)
  7. 使用Xilisoft iPad Magic Platinum for Mac将任何视频/音频转换和传输到 iPad/iPod/iPhone/iTunes?
  8. 关于苹果Mac上设置固件密码的方法?
  9. 无痕埋点(声明式)(原创)
  10. sed学习笔记(1) - 入门知识