302868: CF556A. Case of the Zeros and Ones
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Case of the Zeros and Ones
题意翻译
# 题目描述 安德鲁德是一位银河著名的侦探。 在空闲时间,他喜欢思考包含零和字符串的字符串。 有一次,他想到了一串由零和一组成的长度为n的字符串。 考虑以下操作:我们在字符串中选择任意两个相邻的位置,如果其中一个包含0,另一个包含1,则允许从字符串中移除这两个数字,从而获得长度为n - 2的字符串,作为 结果。 现在,安德鲁德考虑了多次应用所描述的操作(可能是零)后可以保留的字符串的最小长度是多少? 帮助他计算这个数字。 # 输入 输入的第一行包含一个整数n(1≤n≤2.105),即Andreid所具有的字符串的长度。 第二行包含长度为n的字符串,仅由0和1组成。 # 输出 输出多次应用描述的操作后可能保留的字符串的最小长度。 感谢@HNYLMS_MuQiuFeng 提供的翻译题目描述
Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones. Once he thought about a string of length $ n $ consisting of zeroes and ones. Consider the following operation: we choose any two adjacent positions in the string, and if one them contains 0, and the other contains 1, then we are allowed to remove these two digits from the string, obtaining a string of length $ n-2 $ as a result. Now Andreid thinks about what is the minimum length of the string that can remain after applying the described operation several times (possibly, zero)? Help him to calculate this number.输入输出格式
输入格式
First line of the input contains a single integer $ n $ ( $ 1<=n<=2·10^{5} $ ), the length of the string that Andreid has. The second line contains the string of length $ n $ consisting only from zeros and ones.
输出格式
Output the minimum length of the string that may remain after applying the described operations several times.
输入输出样例
输入样例 #1
4
1100
输出样例 #1
0
输入样例 #2
5
01010
输出样例 #2
1
输入样例 #3
8
11101111
输出样例 #3
6