Play with Exponents
All submissions for this problem are available.
Samuel has n boxes of blue balls to dispatch to his clients. Each of the boxes is numbered from 1 to n, such that the number of blue balls in each box - a(i) is such that a(1), a(2) … a(n) are sorted in non-decreasing order.
In a complex encoding of his records that Samuel follows, he writes integers 2a(1), 2a(2), 2a(3) ….. 2a(n) on paper. Now in order to represent this set of boxes, he requires to find the minimum number of integers of the type 2m (m is non-negative) that must be written on his piece of paper (as described earlier) such that the sum total of all integers present on the paper equals (2k - 1) for some integer k (k is non-negative)
The input consists of an integer n in first line. The second input line contains n space-separated integers a(1), a(2), ..., a(n).
Consists of a single integer - required answer.
1 ≤ n ≤ 105
0 ≤ a(i) ≤ 2.109
a(1) ≤ a(2) ≤ a(3) ....... ≤ a(n)
Input: 3 0 1 2 Output: 0
|Time Limit:||2 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions