|| ||Code Submission Evaluation System
E4590 2018 1
Tasks | Scoreboard | Statistics
CSES - E4590 2018 1 - DenominationsCSES - Denominations
|Time limit:||1.00 s|
|Memory limit:||512 MB|
The country of Oopse has grown and it needs to produce its own currency. The Oopsians have chosen to produce coins and notes with denominations $c_1, c_2, \ldots, c_n$. Unfortunately they are not sure whether given denominations can be used to pay for products of any price.
Help Oopsians find out whether they can pay for products of any price, and if not, what is the smallest price they can't pay for. Any coin or note can be used as many times as needed.
The first line of input consists of a single integer $n$, the number of denominations. The second line has $n$ integers, the denominations $c_1, c_2, \ldots, c_n$, separated by spaces.
Output either the smallest price which can't be paid using the given denominations, or the string "ALL" if all products of any price can be paid.
- $1 \le n \le 10^6$
- $1 \le c_1 < c_2 < \ldots < c_n \le 10^9$
1 2 5 10 20 50 100 200 500 1000 2000 5000 10000 20000 50000
Explanation of example 2
The given values are all Euro denominations in cents. You can produce any amount using Euros.