{"problem":{"name":"Robot Takahashi","description":{"content":"There are $N$ people, each of whom is either a child or an adult. The $i$\\-th person has a weight of $W_i$.   Whether each person is a child or an adult is specified by a string $S$ of length $N$ cons","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc257_c"},"statements":[{"statement_type":"Markdown","content":"There are $N$ people, each of whom is either a child or an adult. The $i$\\-th person has a weight of $W_i$.  \nWhether each person is a child or an adult is specified by a string $S$ of length $N$ consisting of `0` and `1`.  \nIf the $i$\\-th character of $S$ is `0`, then the $i$\\-th person is a child; if it is `1`, then the $i$\\-th person is an adult.\nWhen Takahashi the robot is given a real number $X$, Takahashi judges a person with a weight less than $X$ to be a child and a person with a weight more than or equal to $X$ to be an adult.  \nFor a real value $X$, let $f(X)$ be the number of people whom Takahashi correctly judges whether they are children or adults.\nFind the maximum value of $f(X)$ for all real values of $X$.\n\n## Constraints\n\n*   $1\\leq N\\leq 2\\times 10^5$\n*   $S$ is a string of length $N$ consisting of `0` and `1`.\n*   $1\\leq W_i\\leq 10^9$\n*   $N$ and $W_i$ are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$S$\n$W_1$ $W_2$ $\\ldots$ $W_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc257_c","tags":[],"sample_group":[["5\n10101\n60 45 30 40 80","4\n\nWhen Takahashi is given $X=50$, it judges the $2$\\-nd, $3$\\-rd, and $4$\\-th people to be children and the $1$\\-st and $5$\\-th to be adults.  \nIn reality, the $2$\\-nd and $4$\\-th are children, and the $1$\\-st, $3$\\-rd, and $5$\\-th are adults, so the $1$\\-st, $2$\\-nd, $4$\\-th, and $5$\\-th people are correctly judged. Thus, $f(50)=4$.\nThis is the maximum since there is no $X$ that judges correctly for all $5$ people. Thus, $4$ should be printed."],["3\n000\n1 2 3","3\n\nFor example, $X=10$ achieves the maximum value $f(10)=3$.  \nNote that the people may be all children or all adults."],["5\n10101\n60 50 50 50 60","4\n\nFor example, $X=55$ achieves the maximum value $f(55)=4$.  \nNote that there may be multiple people with the same weight."]],"created_at":"2026-03-03 11:01:14"}}