Telephone Numbers
Time limit1sMemory limit1024 MB
Given a list of numbers, the task finds the smallest one whose digits are all equal or strictly increasing, or prints NERASTA if none exists.
- Level
Easy2 of 10
- Topics
- Implementation, Sorting
- Solved
- No attempts yet
Problem
Vilius is starting a business that delivers pictures to homes. He only needs to choose and buy an easy-to-remember phone number. Vilius has a list of phone numbers that he can buy.
He considers a number memorable only if all of its digits are equal (for example, 2222), or if its digits strictly increase (for example, 23679).
Find a memorable number in the given list.
Input
The first line contains the number of phone numbers, N. Each of the next N lines contains one distinct positive integer K.
Output
Print one memorable number. If the list has several memorable numbers, print the smallest one. If the list has no memorable numbers, print NERASTA.
Constraints
1 ≤ N ≤ 1 000
1 ≤ K ≤ 100 000