아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Juggler's Trick

시간 제한3초메모리 제한1024 MB

요약
흰 공을 빨강 또는 파랑으로 칠한 뒤, 빨강 r개와 파랑 b개로 이루어진 연속 구간을 최대한 여러 번 제거하는 문제입니다.
난이도

보통10점 중 7점

유형
그리디, 누적 합, 문자열
정답자
아직 제출이 없습니다

문제

NN balls are lined up in a row from left to right. Each ball may be either uncolored (white), blue, or red. Additionally, two integers rr and bb are given. Let us represent the ordering as a string consisting of letters 'W', 'B' and 'R' for uncolored, black, and red balls, respectively.

For each trick, the juggler may choose a combo of r+br + b consecutive balls such that there are exactly rr red balls and exactly bb blue balls, in any order, and remove them. The remaining balls are concatenated while keeping their relative order. For example, if the initial order was "RRBRBBR", and the juggler removed "RBB", the result would be "RRBR".

Before the process starts, the juggler shall paint each uncolored ball either red or blue. The juggler wants to do as many tricks as possible. Find the maximal number of tricks if the juggler will choose the colors for the uncolored balls optimally.

입력

The first line of input contains three integers NN, rr and bb (1≤N≤2⋅1051 \le N \le 2 \cdot 10^5, 1≤r,b≤N−11 \le r,b \le N-1, r+b≤Nr+b \le N): the total number of balls, the number of red balls in a combo and the number of the blue balls in a combo, respectively. The second line contains the string SS. This string encodes the initial order of balls and consists of exactly NN letters 'B', 'R' and 'W', representing blue, red, and uncolored balls, respectively.

출력

Print one integer: the maximum number of tricks that can be done by the juggler.

힌트

In Example 1, the juggler paints the white ball in red, obtaining the order "BBRR", then removes combo "BR"; the remaining balls have order "BR", so they can be removed. Since there are 4 balls initially, and after each trick, exactly two balls are removed, 2 is the maximal possible number of tricks that can be done.

In Example 2, the juggler cannot obtain any sequence of 3 balls with two red and one blue ball regardless of the coloring of the white ball, so the answer is 0.

예제3

  1. 예제 1

    입력
    4 1 1
    BBWR
    
    예상 출력
    2
    
  2. 예제 2

    입력
    6 2 1
    RBBBWB
    
    예상 출력
    0
    
  3. 예제 3

    입력
    13 3 3
    WWWWWWWWWWWWW
    
    예상 출력
    2