December Lunchtime 2021 - Chef Loves 1010 solution - CHEF1010
Chef Loves 1010 Problem Code: CHEF1010
Chef is given a binary string of length . As Chef loves and he is busy in the preparation of Christmas, he asks you to count the maximum number of continuous substrings , which Chef can get after reordering symbols in the given string.
As a reminder, a binary string is a string consisting only of 's ans 's.
Input Format
- The first line of the input contains a single integer - the number of test cases. The test cases then follow.
- The first line of the test case contains an integer - the length of the binary string.
- The second line of each test case contains the binary string .
Output Format
For each test case, print maximum number of continuous substrings , which Chef can get after reordering symbols in the string.
Constraints
- is a binary string
Subtasks
- Subtask (100 points): Original constraints
Sample Input 1
3
2
11
8
11000100
10
0100111100
Sample Output 1
0
2
4
Explanation
- Test case : There are no s in the string, so a substring is not possible.
- Test case : We can reorder string into , in which the first starts from index , and the second starts from index . It can be proven that there are no orderings that give the answer larger than .
https://discuss.codechef.com/problems/CHEF1010
Tags are hidden. Show temporarily
Update this setting in edit profile
Cakewalk
19-12-2021
1 secs
50000 Bytes
CPP14, C, JAVA, PYTH 3.6, CPP17, PYTH, PYP3, CS2, ADA, PYPY, TEXT, PAS fpc, NODEJS, RUBY, PHP, GO, HASK, TCL, PERL, SCALA, LUA, kotlin, BASH, JS, LISP sbcl, rust, PAS gpc, BF, CLOJ, R, D, CAML, FORT, ASM, swift, FS, WSPC, LISP clisp, SQL, SCM guile, PERL6, ERL, CLPS, ICK, NICE, PRLG, ICON, COB, SCM chicken, PIKE, SCM qobi, ST, SQLQ, NEM
Comments
Post a Comment