codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

864A.md (2669B)


      1 Source: https://codeforces.com/problemset/problem/864/A
      2 
      3 A. Fair Game
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 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.
     22 
     23 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.
     24 
     25 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.
     26 
     27 Determine whether Petya and Vasya can choose integer numbers before the game so that the game is fair.
     28 
     29 Input
     30 
     31 The first line contains a single integer *n* (2 ≤ *n* ≤ 100) — number of cards. It is guaranteed that *n* is an even number.
     32 
     33 The following *n* lines contain a sequence of integers *a*1, *a*2, ..., *a**n* (one integer per line, 1 ≤ *a**i* ≤ 100) — numbers written on the *n* cards.
     34 
     35 Output
     36 
     37 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.
     38 
     39 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.
     40 
     41 Examples
     42 
     43 Input
     44 
     45 ```
     46 4  
     47 11  
     48 27  
     49 27  
     50 11
     51 ```
     52 
     53 Output
     54 
     55 ```
     56 YES  
     57 11 27
     58 ```
     59 
     60 Input
     61 
     62 ```
     63 2  
     64 6  
     65 6
     66 ```
     67 
     68 Output
     69 
     70 ```
     71 NO
     72 ```
     73 
     74 Input
     75 
     76 ```
     77 6  
     78 10  
     79 20  
     80 30  
     81 20  
     82 10  
     83 20
     84 ```
     85 
     86 Output
     87 
     88 ```
     89 NO
     90 ```
     91 
     92 Input
     93 
     94 ```
     95 6  
     96 1  
     97 1  
     98 2  
     99 2  
    100 3  
    101 3
    102 ```
    103 
    104 Output
    105 
    106 ```
    107 NO
    108 ```
    109 
    110 Note
    111 
    112 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.
    113 
    114 In the second example fair game is impossible because the numbers written on the cards are equal, but the numbers that Petya and Vasya should choose should be distinct.
    115 
    116 In the third example it is impossible to take all cards. Petya and Vasya can take at most five cards — for example, Petya can choose number 10 and Vasya can choose number 20. But for the game to be fair it is necessary to take 6 cards.