codeforces-scrape

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

862A.md (1789B)


      1 Source: https://codeforces.com/problemset/problem/862/A
      2 
      3 A. Mahmoud and Ehab and the MEX
      4 
      5 time limit per test
      6 
      7 2 seconds
      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 Dr. Evil kidnapped Mahmoud and Ehab in the evil land because of their performance in the Evil Olympiad in Informatics (EOI). He decided to give them some problems to let them go.
     22 
     23 Dr. Evil is interested in sets, He has a set of *n* integers. Dr. Evil calls a set of integers evil if the MEX of it is exactly *x*. the MEX of a set of integers is the minimum non-negative integer that doesn't exist in it. For example, the MEX of the set {0, 2, 4} is 1 and the MEX of the set {1, 2, 3} is 0 .
     24 
     25 Dr. Evil is going to make his set evil. To do this he can perform some operations. During each operation he can add some non-negative integer to his set or erase some element from it. What is the minimal number of operations Dr. Evil has to perform to make his set evil?
     26 
     27 Input
     28 
     29 The first line contains two integers *n* and *x* (1 ≤ *n* ≤ 100, 0 ≤ *x* ≤ 100) — the size of the set Dr. Evil owns, and the desired MEX.
     30 
     31 The second line contains *n* distinct non-negative integers not exceeding 100 that represent the set.
     32 
     33 Output
     34 
     35 The only line should contain one integer — the minimal number of operations Dr. Evil should perform.
     36 
     37 Examples
     38 
     39 Input
     40 
     41 ```
     42 5 3  
     43 0 4 5 6 7
     44 ```
     45 
     46 Output
     47 
     48 ```
     49 2
     50 ```
     51 
     52 Input
     53 
     54 ```
     55 1 0  
     56 0
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 1
     63 ```
     64 
     65 Input
     66 
     67 ```
     68 5 0  
     69 1 2 3 4 5
     70 ```
     71 
     72 Output
     73 
     74 ```
     75 0
     76 ```
     77 
     78 Note
     79 
     80 For the first test case Dr. Evil should add 1 and 2 to the set performing 2 operations.
     81 
     82 For the second test case Dr. Evil should erase 0 from the set. After that, the set becomes empty, so the MEX of it is 0.
     83 
     84 In the third test case the set is already evil.