atcoder#ABC257C. [ABC257C] Robot Takahashi
[ABC257C] Robot Takahashi
Score : points
Problem Statement
There are people, each of whom is either a child or an adult. The -th person has a weight of .
Whether each person is a child or an adult is specified by a string of length consisting of 0
and 1
.
If the -th character of is 0
, then the -th person is a child; if it is 1
, then the -th person is an adult.
When Takahashi the robot is given a real number , Takahashi judges a person with a weight less than to be a child and a person with a weight more than or equal to to be an adult. For a real value , let be the number of people whom Takahashi correctly judges whether they are children or adults.
Find the maximum value of for all real values of .
Constraints
- is a string of length consisting of
0
and1
. - and are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the maximum value of as an integer in a single line.
5
10101
60 45 30 40 80
4
When Takahashi is given , it judges the -nd, -rd, and -th people to be children and the -st and -th to be adults. In reality, the -nd and -th are children, and the -st, -rd, and -th are adults, so the -st, -nd, -th, and -th people are correctly judged. Thus, .
This is the maximum since there is no that judges correctly for all people. Thus, should be printed.
3
000
1 2 3
3
For example, achieves the maximum value . Note that the people may be all children or all adults.
5
10101
60 50 50 50 60
4
For example, achieves the maximum value . Note that there may be multiple people with the same weight.