#575. 「Nowcoder多校 2019 Day3」Crazy Binary String

「Nowcoder多校 2019 Day3」Crazy Binary String

当前没有测试数据。

题目描述

ZYB loves binary strings (strings that only contains '0' and '1'). And he loves equal binary strings more, where the number of '0' and the number of '1' in the string are equal.

ZYB wants to choose a substring from an original string  T\ T so that it is an equal binary string with the longest length possible. He also wants to choose a subsequence of  T\ T which meets the same requirements.

A string  v\ v is a substring of a string  w\ w if  v\ v is empty, or there are two integers  l\ l and  (1lrw)\ (1 \le l \le r \le |w|) such that v=wl​wl+1​⋯wr​. A string  v\ v is a subsequence of a string  w\ w if it can be derived from  w\ w by deleting any number (including zero) of characters without changing the order of the remaining characters.

For simplicity, you only need to output the maximum possible length. Note that the empty string is both a substring and a subsequence of any string.

输入格式

The first line of the input contains a single integer  (1N100000) \ (1 \le N \leq 100000), the length of the original string  T\ T . The second line contains a binary string with exactly  N\ N characters, the original string  T\ T .

输出格式

Print two integers  A\ A and  B\ B , denoting the answer for substring and subsequence respectively.

样例

样例输入 1

8
01001001

样例输出 1

4 6