Champernowne Subsequence
시간 제한2초메모리 제한2048 MB
숫자 문자열이 주어질 때, 1부터 k까지 이어 붙인 문자열의 부분 수열이 되는 가장 작은 k를 구한다.
문제
The Champernowne word is obtained by writing down the first positive integers and concatenating them together. For example, the Champernowne word is .
It can be proven that, for any finite string of digits, there exists some integer such that the finite string of digits will appear as a subsequence in the Champernowne word.
String is a subsequence of string if it is possible to delete some (possibly zero) characters from to get .
Given a string of digits, compute the smallest integer such that the given string of digits is a subsequence of the Champernowne word.
입력
The first line of input contains a single integer , the length of the string of digits.
The second line of input contains a string of digits.
출력
Output a single integer , the minimum integer such that the given string is a subsequence of the Champernowne word.