|
| 1 | +import java.io.*; |
| 2 | +import java.util.*; |
| 3 | + |
| 4 | +/* |
| 5 | + * 준표의 조약돌 |
| 6 | + */ |
| 7 | + |
| 8 | +public class DH_15831 { |
| 9 | + public static void main(String[] args) throws Exception { |
| 10 | + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); |
| 11 | + StringTokenizer st = new StringTokenizer(br.readLine()); |
| 12 | + |
| 13 | + int N = Integer.parseInt(st.nextToken()); // 조약돌의 총 개수 |
| 14 | + int B = Integer.parseInt(st.nextToken()); // 검은 조약돌의 최대 개수 |
| 15 | + int W = Integer.parseInt(st.nextToken()); // 하얀 조약돌의 최소 개수 |
| 16 | + |
| 17 | + String str = br.readLine(); |
| 18 | + |
| 19 | + int s = 0, e = 0, bCnt = 0, wCnt = 0, answer = 0; |
| 20 | + |
| 21 | + while(e < N) { |
| 22 | + if(B < bCnt) { // 검정 조약돌의 개수가 크다면 start 지점 오른쪽으로 |
| 23 | + if(str.charAt(s) == 'B') bCnt -= 1; |
| 24 | + else wCnt -= 1; |
| 25 | + s += 1; |
| 26 | + } else { // 하얀 조약돌의 개수가 작다면 end 지점 오른쪽으로 |
| 27 | + if(str.charAt(e) == 'B') bCnt += 1; |
| 28 | + else wCnt += 1; |
| 29 | + |
| 30 | + e += 1; |
| 31 | + } |
| 32 | + |
| 33 | + if(bCnt <= B && wCnt >= W) answer = Math.max(answer, e - s); |
| 34 | + } |
| 35 | + |
| 36 | + System.out.println(answer); |
| 37 | + } |
| 38 | +} |
0 commit comments