#BS0000164. Rô-bốt phân biệt trẻ em và người lớn (Robot Takahashi)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Rô-bốt phân biệt trẻ em và người lớn (Robot Takahashi)
Robot Takahashi
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
There are people, each truly a child or an adult. The string gives the true labels: for a child and for an adult. Person has integer weight . Given any real threshold , a robot labels weights strictly less than as children and weights greater than or equal to as adults. Let be the number of correct labels. Find the maximum possible over all real .
Input
- Line 1 contains integer .
- Line 2 contains binary string of length .
- Line 3 contains integers .
Output
Print one integer: the maximum number of people the robot can classify correctly.
Subtasks
- Subtask 1 (20 points): ; for all ; contains only
0,1and has length . - Subtask 2 (30 points): ; for all ; contains only
0,1and has length . - Subtask 3 (50 points): ; for all ; contains only
0,1and has length .
Examples
Input
5
10101
60 45 30 40 80
Output
4
Explanation
Choose : people with weights are classified as adults, and people with weights as children. The true labels 10101 mean people 1, 3, 5 are adults, and 2, 4 are children. People 1, 2, 4, 5 are classified correctly, giving . It is impossible to classify all 5 correctly because the adult of weight and the child of weight cannot both be correctly classified by one threshold.