Subsequence of AB
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Time Limit: 1.0 s
Memory Limit: 128.0 MB
Description
You are given a string S and the length of the string is N. You need to perform at most K operations (Possibly zero) of the string S.
In each operation,
You can choose an index \(i\), \(1<= i<= N\), where \(S[i]\)=?, change its character by either A or B.(Ex. \(S[i] = A\) or \(S[i] = B\)).
After perfroming above operation on string S, find the occurrence of "AB" as the subsequence of final string S.
For example, Subsequence of string S=\(ABC\) -> {\(A,B,C,AB,AC,BC,ABC\)}.
You need to perform operation such way that, total occurrence of "AB" is as maximum as possible.
Input
First line T, the number of test cases.
In each test case, first line two positive integers N and K.
Second line, a string S, the length of string is N.
\(1<=T<=10000\)
\(1<= N <= 2 * 10^5\)
\(1<= K <= 10^9\)
String \(S\) contains english uppercase alphabets and \(?\) .
Sum of \(N\) overall test case doesn't exceed \(2 * 10^5\)
Output
In each test case, print the maximum occurrence of AB as the subsequence of final string S.
Sample
Input | Output |
---|---|
|
|
Brain Booster #7
- Status
- Done
- Rule
- ACM/ICPC
- Problem
- 8
- Start at
- 2024-11-05 14:30
- End at
- 2024-11-05 16:45
- Duration
- 2.2 hour(s)
- Host
- Partic.
- 142