#P6740. [BalticOI 2014] Sequence (Day1)
[BalticOI 2014] Sequence (Day1)
Description
There are now consecutive positive integers. For each integer, you can only see one of its digits. Find the minimum possible value of the first number .
Input Format
The first line contains an integer , representing the length of the sequence.
The second line contains integers, representing the digits you can see.
Output Format
Output one integer in a single line, representing the minimum possible value of .
6
7 8 9 5 1 2
47
Hint
Sample Explanation
For sample , the sequence that makes minimal is , and the minimum value of is .
Constraints
This problem uses bundled testdata.
- Subtask 1 (9 pts): .
- Subtask 2 (33 pts): .
- Subtask 3 (25 pts): all given digits are equal.
- Subtask 4 (33 pts): no special constraints.
For of the data, .
This problem enforces O2 optimization.
Notes
Translated from BalticOI 2014 Day1 C Sequence。
Translated by ChatGPT 5
京公网安备 11011102002149号