This post is all about the solution of the "B. Maximum Substring" CodeTON Round 3 (Div. 1 + Div. 2, Rated, Prizes!) Problem Solution.

B. Maximum Substring CodeTON Round 3 (Div. 1 + Div. 2, Rated, Prizes!) Problem Solution

Codeforces



Problem Statement :

A binary string is a string that only contains the numbers zero and one. You have been given the binary string s.

Describe the cost of certain non-empty sequence t of string s actually contains x characters 0 and y characters 1 as:

xy, if x > 0 and y > 0; x2, if x > 0 and y = 0; y2, if x = 0 and y > 0.
Determine the maximum cost throughout all non-empty subsequences of a binary string s of duration n.

A string an is a subsequence of a string b if a could be acquired from b by deleting several (potentially, 0, or all) characters at the start as well as several (possibly, “ 0 ”, or all) characters at the finish.


Format of Input :

So every test is made up of several test cases. The very first line contains a single integer t (1t105), which represents the number of tests. The following is an overview of the tests.

Evey test case begins with a single int n (1n2105) — the length of the string s.

Evey test court's second sentence contains a binary string s of duration n.

The total amount of n over all tests is assured not to surpass 2105.

Format of the Output :

output the maximum cost of across substring

Also Check this out:-

A. Indirect Sort CodeTON Round 3 (Div. 1 + Div. 2, Rated, Prizes!) Problem Solution Click Here

Also Read :- Top Programming Languages of 2022 Click Here

Solution of the Problem: Click Here