P27039 [AtCoder] I made a huge number
省选
题目描述

Problem Description

Joishino sister came to a small branch school located in a peaceful countryside. It seems that a special game is popular in this school.

The rules of the game are as follows:

  1. This game is played by two people.
  2. One person first selects several different natural numbers, arranges them in ascending order from right to left, and concatenates them to form a new number.
  3. Natural numbers referred to here are integers greater than or equal to $ 1 $ and do not have leading zeros. For example, $ 01 $ or $ 0099 $ are not allowed.
    (For example, if the selected natural numbers are $ 5 $, $ 18 $, $ 48 $, $ 52 $, then the number formed is $ 5248185 $.)
  4. Then, the created number is shown to the opponent.
  5. The person who is shown the number guesses one set of the original numbers that could have been used to form the number.
  6. If the largest number in the guessed set is less than or equal to the largest number in the set used to form the number, the guesser wins; otherwise, the person who created the number wins.
    Joishino sister is going to play this game with a certain elementary school student. It seems that this student has made a large number during the long vacation. As the guesser, Joishino sister wants to win this game for the sake of her pride. She realized that the guesser can always win by playing optimally. Therefore, being an excellent programmer, Joishino sister decided to create a program that calculates the minimum number of digits that the largest number in the set of numbers that can form the given number can have.

Input Format

The input is given from the standard input in the following format:

$ N $ $ S $

  • The first line contains the number of digits $N (1 \leq N \leq 10^6)$ of the given number.
  • The second line contains the $ N $-digit number (it is guaranteed that the leading digit of this number is not zero).

Output Format

Output the minimum number of digits of the largest number in the set of numbers that can form the given number.
Output this number in one line. Also, include a newline at the end of the output.

Sample Input and Output

Sample Input #1

7
5248185

Sample Output #1

2

Sample Input #2

9
123456789

Sample Output #2

4

Sample Input #3

20
49260520598009034978

Sample Output #3

8

Notes/Hints

Scoring

This problem has partial points.

  1. Dataset $ 1 $ satisfies $N (1 \leq N \leq 10^4)$, and correct answer gives $ 15 $ points.
  2. Dataset $ 2 $ has no additional constraints, and correct answer gives $ 125 $ points.

Sample Explanation 1

  • When the set of numbers is $ 52 $, $ 48 $, $ 18 $, $ 5 $, the largest number (52) has the minimum number of digits (2 digits).

Sample Explanation 2

  • When the set of numbers is $ 1234 $, $ 567 $, $ 89 $, the largest number (1234) has the minimum number of digits (4 digits).
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
7 5248185
样例输出
2