找规律/贪心 Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones

时间:2022-05-22 15:48:24

题目传送门

 /*
找规律/贪心:ans = n - 01匹配的总数,水
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std; const int MAXN = 2e5 + ;
const int INF = 0x3f3f3f3f;
char s[MAXN]; int main(void) //Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones
{
// freopen ("A.in", "r", stdin); int n;
while (scanf ("%d", &n) == )
{
scanf ("%s", s);
int cnt_0 = , cnt_1 = ;
for (int i=; i<n; ++i)
{
if (s[i] == '') cnt_0++;
else cnt_1++;
} printf ("%d\n", n - min (cnt_0, cnt_1) * );
} return ;
}