codeforces-scrape

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

682B.md (1893B)


      1 Source: https://codeforces.com/problemset/problem/682/B
      2 
      3 B. Alyona and Mex
      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 Someone gave Alyona an array containing *n* positive integers *a*1, *a*2, ..., *a**n*. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not apply any operation to the array at all.
     22 
     23 Formally, after applying some operations Alyona will get an array of *n* positive integers *b*1, *b*2, ..., *b**n* such that 1 ≤ *b**i* ≤ *a**i* for every 1 ≤ *i* ≤ *n*. Your task is to determine the maximum possible value of mex of this array.
     24 
     25 Mex of an array in this problem is the minimum positive integer that doesn't appear in this array. For example, mex of the array containing 1, 3 and 4 is equal to 2, while mex of the array containing 2, 3 and 2 is equal to 1.
     26 
     27 Input
     28 
     29 The first line of the input contains a single integer *n* (1 ≤ *n* ≤ 100 000) — the number of elements in the Alyona's array.
     30 
     31 The second line of the input contains *n* integers *a*1, *a*2, ..., *a**n* (1 ≤ *a**i* ≤ 109) — the elements of the array.
     32 
     33 Output
     34 
     35 Print one positive integer — the maximum possible value of mex of the array after Alyona applies some (possibly none) operations.
     36 
     37 Examples
     38 
     39 Input
     40 
     41 ```
     42 5  
     43 1 3 3 3 6
     44 ```
     45 
     46 Output
     47 
     48 ```
     49 5
     50 ```
     51 
     52 Input
     53 
     54 ```
     55 2  
     56 2 1
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 3
     63 ```
     64 
     65 Note
     66 
     67 In the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.
     68 
     69 To reach the answer to the second sample case one must not decrease any of the array elements.