Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int cnt[105];
- signed main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- int t , n;
- string s;
- cin >> t;
- int ans = 0;
- while(t--){
- cin >> n;
- cin >> s;
- int x = 0 , y = 0;
- for(int i = 0; i < s.size(); i++){
- if(s[i] == '1')
- x++;
- else
- y++;
- }
- cout << min(x , y + 1) << '\n';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement