Description

Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card.

Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number that Petya chose). During the game each player takes all the cards with number he chose. For example, if Petya chose number 5 before the game he will take all cards on which 5 is written and if Vasya chose number 10 before the game he will take all cards on which 10 is written.

The game is considered fair if Petya and Vasya can take all n cards, and the number of cards each player gets is the same.

Determine whether Petya and Vasya can choose integer numbers before the game so that the game is fair.

Input

The first line contains a single integer n (2 ≤ n ≤ 100) — number of cards. It is guaranteed that n is an even number.

The following n lines contain a sequence of integers a1, a2, ..., an (one integer per line, 1 ≤ ai ≤ 100) — numbers written on the n cards.

Output

If it is impossible for Petya and Vasya to choose numbers in such a way that the game will be fair, print "NO" (without quotes) in the first line. In this case you should not print anything more.

In the other case print "YES" (without quotes) in the first line. In the second line print two distinct integers — number that Petya should choose and the number that Vasya should choose to make the game fair. If there are several solutions, print any of them.

Sample Input

  1. 411272711

Sample Output

  1. YES11 27

HINT

In the first example the game will be fair if, for example, Petya chooses number 11, and Vasya chooses number 27. Then the will take all cards — Petya will take cards 1 and 4, and Vasya will take cards 2 and 3. Thus, each of them will take exactly two cards.

题解

果然题目看不懂是硬伤...

就是问你一个长度为$n$数列中($2|n$),是否有一种划分方式,划分成等长的两个序列使各个序列数相同...

I think there is no need to tell you how to solve this problem...

  1. //It is made by Awson on 2017.9.29
  2. #include <set>
  3. #include <map>
  4. #include <cmath>
  5. #include <ctime>
  6. #include <queue>
  7. #include <stack>
  8. #include <vector>
  9. #include <cstdio>
  10. #include <string>
  11. #include <cstring>
  12. #include <cstdlib>
  13. #include <iostream>
  14. #include <algorithm>
  15. #define LL long long
  16. #define Max(a, b) ((a) > (b) ? (a) : (b))
  17. #define Min(a, b) ((a) < (b) ? (a) : (b))
  18. #define sqr(x) ((x)*(x))
  19. #define lowbit(x) ((x)&(-(x)))
  20. using namespace std;
  21. void read(int &x) {
  22. ;
  23. ); ch = getchar());
  24. ; isdigit(ch); x = (x<<)+(x<<)+ch-, ch = getchar());
  25. x *= -*flag;
  26. }
  27.  
  28. int n, a;
  29. ];
  30.  
  31. void work() {
  32. read(n);
  33. ; i <= n; i++)
  34. read(a), sum[a] += ;
  35. ;
  36. ; i <= ; i++)
  37. cnt += (bool)sum[i];
  38. ) {
  39. ; i <= ; i++)
  40. ) {
  41. printf("NO\n");
  42. return;
  43. }
  44. printf("YES\n");
  45. ; i <= ; i++)
  46. if (sum[i]) printf("%d ", i);
  47. printf("\n");
  48. }
  49. else printf("NO\n");
  50. }
  51. int main() {
  52. work();
  53. ;
  54. }

[Codeforces 864A]Fair Game的更多相关文章

  1. CodeForces - 987D Fair (BFS求最短路)

    题意:有N个城市,M条双向道路连接两个城市,整个图保证连通.有K种物品,但每个城市只有一种,现在它们都需要S种物品来举办展览,可以去其他城市获取该城市的物品,花费是两城市之间的最短路径长度.求每个城市 ...

  2. CodeForces - 986A Fair (BFS+贪心)

    题意:有N个点M条边的无向图,每个点有给定的ai(1<=ai<=K,K<=200)表示该点拥有的物品编号,保证1-K在N个点全部出现.求每个点收集S个不同的物品所要走过的最短路程(边 ...

  3. [CodeForces]986A Fair

    大意:给一张图,每个图上有一个数,问以每个点为源点,经过的点包含k种数字的最小距离. 显然跑最短路会T,但我们注意到边权一定.某次学校考试就是类似题,可以bfs做,复杂度O(n),每种货物做一次,复杂 ...

  4. Codeforces 986A. Fair(对物品bfs暴力求解)

    解题思路: 1.对物品i bfs,更新每个小镇j获得每个物品i的最短距离. 2.时间复杂度o(n*k),满足2s的要求. 代码: #include <iostream> #include ...

  5. codeforces 897A Scarborough Fair 暴力签到

    codeforces 897A Scarborough Fair 题目链接: http://codeforces.com/problemset/problem/897/A 思路: 暴力大法好 代码: ...

  6. Codeforces Round #485 (Div. 2) D. Fair

    Codeforces Round #485 (Div. 2) D. Fair 题目连接: http://codeforces.com/contest/987/problem/D Description ...

  7. Educational Codeforces Round 8 F. Bear and Fair Set 最大流

    F. Bear and Fair Set 题目连接: http://www.codeforces.com/contest/628/problem/F Description Limak is a gr ...

  8. Codeforces Round #526 (Div. 2) E. The Fair Nut and Strings

    E. The Fair Nut and Strings 题目链接:https://codeforces.com/contest/1084/problem/E 题意: 输入n,k,k代表一共有长度为n的 ...

  9. Codeforces Round #526 (Div. 2) D. The Fair Nut and the Best Path

    D. The Fair Nut and the Best Path 题目链接:https://codeforces.com/contest/1084/problem/D 题意: 给出一棵树,走不重复的 ...

随机推荐

  1. JavaScript(第九天)【正则表达式】

    假设用户需要在HTML表单中填写姓名.地址.出生日期等.那么在将表单提交到服务器进一步处理前,JavaScript程序会检查表单以确认用户确实输入了信息并且这些信息是符合要求的.   一.什么是正则表 ...

  2. 关于hadoop集群下Datanode和Namenode无法访问的解决方案

    HDFS架构 HDFS也是按照Master和Slave的结构,分namenode,secondarynamenode,datanode这几个角色. Namenode:是maseter节点,是大领导.管 ...

  3. C语言程序设计(基础)- 第4周作业

    一.PTA作业 完成PTA第四周作业中8个题目,并将其中4个题目的思路列在博客中. 1.7-1 计算分段函数[1] 2.7-2 A除以B 3.7-6 阶梯电价 4.7-7 出租车计价 随笔具体书写内容 ...

  4. 转:运行page页面时的事件执行顺序及页面的回发与否深度了解

    using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Secu ...

  5. C语言第五次博客作业

    一.PTA实验作业 题目1:6-6 使用函数输出水仙花数 1. 本题PTA提交列表 2. 设计思路 (1) 首先先定义narcissistic函数. (2)定义四个整形变量n,a,d,cnt,sum, ...

  6. VS系列控制台闪退解决

    查阅--->总结-->实践--> 按红色标识走 ,完美解决! 至此,完美解决:原理不深究:

  7. IE bug:ajax请求返回304解决方案

    bug说明: 同一账户下的默认收货地址只有一个,默认收货地址可以修改,修改完成后,使用ajax重新加载收货地址部分. 默认收货地址状态标记:status = 1: 在IE浏览器做了修改后,重新加载的数 ...

  8. python生成单词壁纸

    1.首先上结果: 其实就是一段简单的代码.加上英语单词表加上几张背景图生成许多类似的图片再设置成桌面背景,十分钟一换.有心的人闲的时候随手就能换换桌面背背单词.最不济也能混个脸熟. 3.上代码 #-* ...

  9. api-gateway实践(15)API网关的待改进点 20171207

    一.API网关能力 API网关负责服务请求路由.组合及协议转换.客户端的所有请求都首先经过API网关,然后由它将请求路由到合适的微服务.API网关的客户端通过统一的网关接入微服务,在网关层处理所有的非 ...

  10. ios开发常识(1)开发语言和参考资料

    学iphone开发用的语言是object-c,object-c和c++,java还是有很大区别,如果你坚持学习iphone开发的话可以不学c++,java,直接学习这个语言,先入为主,可能觉得这个语言 ...