#K79477. Maximizing Data Samples Collection

    ID: 35317 Type: Default 1000ms 256MiB

Maximizing Data Samples Collection

Maximizing Data Samples Collection

You are given a project period of n days. Each day is either a work day or a maintenance day. The status of a day is represented by a character in a string s where:

  • '1' indicates a day available for data collection.
  • '0' indicates a maintenance day when no data can be collected.

On a work day, you can collect at most $$k_1$$ data samples. However, due to operational constraints, the total number of data samples that can be collected in any two consecutive days cannot exceed $$k_2$$. Note that a maintenance day resets the consecutive-day limitation.

Your task is to compute the maximum total number of data samples that can be collected during the n-day project period.

Additionally, you are required to process multiple test cases. For each test case you will be given the values of n, k_1, k_2, and the string s representing the schedule of days.

Note: When a day is a work day (i.e. the corresponding character in s is '1'), the number of samples you can collect on that day is min(k_1, k_2 - (samples collected on the previous work day)). If the day is a maintenance day ('0'), no samples are collected and the consecutive day count is reset.

inputFormat

The first line of the input contains an integer t (the number of test cases). Following this, for each test case there are two lines:

  • The first line contains three integers: n, k1, and k2, where
    $$1 \leq n \leq 5000,\; 1 \leq k_1 \leq 200000, \; 1 \leq k_2 \leq 200000.$$
  • The second line contains a string s of length n consisting of the characters '0' and '1'.

outputFormat

For each test case, print a single line containing the maximum number of data samples that can be collected.

## sample
5
4 5 7
1011
4 4 10
0101
5 3 4
11011
6 4 6
011101
1 1 1
0
12

8 8 14 0

</p>