🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# Problem A. Magic Box ### Source - [hihoCoder](http://hihocoder.com/contest/mstest2015april/problem/1) ### Problem 鏃堕棿闄愬埗:10000ms 鍗曠偣鏃堕檺:1000ms 鍐呭瓨闄愬埗:256MB ### 鎻忚堪 The circus clown Sunny has a magic box. When the circus is performing, Sunnyputs some balls into the box one by one. The balls are in three colors:red(R), yellow(Y) and blue(B). Let Cr, Cy, Cb denote the numbers of red,yellow, blue balls in the box. Whenever the differences among Cr, Cy, Cbhappen to be x, y, z, all balls in the box vanish. Given x, y, z and thesequence in which Sunny put the balls, you are to find what is the maximumnumber of balls in the box **ever**. For example, let's assume x=1, y=2, z=3 and the sequence is RRYBRBRYBRY. AfterSunny puts the first 7 balls, RRYBRBR, into the box, Cr, Cy, Cb are 4, 1, 2respectively. The differences are exactly 1, 2, 3. (|Cr-Cy|=3, |Cy-Cb|=1, |Cb-Cr|=2) Then all the 7 balls vanish. Finally there are 4 balls in the box,after Sunny puts the remaining balls. So the box contains 7 balls at most,after Sunny puts the first 7 balls and before they vanish. #### 杈撳叆 Line 1: x y z Line 2: the sequence consisting of only three characters 'R', 'Y' and 'B'. For 30% data, the length of the sequence is no more than 200. For 100% data, the length of the sequence is no more than 20,000, 0 <= x,y, z <= 20. ### 杈撳嚭 The maximum number of balls in the box **ever**. ### 鎻愮ず Another Sample | Sample Input | Sample Output | |-----|-----| | (0 0 0)RBYRRBY | 4 | 鏍蜂緥杈撳叆 ~~~ 1 2 3 RRYBRBRYBRY ~~~ 鏍蜂緥杈撳嚭 ~~~ 7 ~~~