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

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

Dogs and Cats

메모리 제한1024 MB

요약
동물을 순서대로 먹이면서 개가 먹을 때마다 고양이 사료 M개를 추가하고, 모든 개가 먹이를 받는지 판정한다.
난이도

보통10점 중 4점

유형
시뮬레이션, 그리디, 구현
정답자
아직 제출이 없습니다

문제

You work for an animal shelter and you are responsible for feeding the animals. You already prepared DD portions of dog food and CC portions of cat food.

There are a total of NN animals waiting in a line, some of which are dogs and others are cats. It might be possible that all the animals in the line are dogs or all the animals are cats. A string SS of NN characters C and D represents the order of cats and dogs in the line. The ii-th character is equal to C if the ii-th animal in the line is a cat. Similarly, the ii-th character is equal to D if the ii-th animal in the line is a dog.

The animals are fed in the order they stay in the line. Each dog eats exactly 11 portion of dog food and similarly each cat eats exactly 11 portion of cat food. Moreover, you have extra portions of cat food. Every time a dog eats food, you bring MM extra portions of cat food for cats.

Animals have to be fed in the order they wait in line and an animal can only eat if the animal before it has already eaten. That means that if you run out of dog (or cat) food portions and a dog (or a cat) is about to get fed, the line will not move, as all the animals will wait patiently.

You need to determine if in this scenario all the dogs in the line will be fed. Note that this means that some cats might remain in the line, but worry not, you will eventually feed them later!

입력

The first line of the input gives the number of test cases, TT. TT test cases follow.

The first line of each test case contains four integers NN, DD, CC, and MM: the number of animals, the initial number of dog food portions, the initial number of cat food portions, and the additional portions of cat food that we add after a dog eats a portion of dog food, respectively.

The next line contains a string SS of length NN representing the arrangement of animals.

출력

For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 11) and yy is YES if all the dogs will be fed and NO otherwise.

제한

  • 1≤T≤1001 \le T \le 100.
  • 1≤N≤1041 ≤ N ≤ 10^4.
  • 0≤D,C≤1060 ≤ D, C ≤ 10^6.
  • SS consists of only characters C and D.

예제2

  1. 예제 1

    입력
    3
    6 10 4 0
    CCDCDD
    4 1 2 0
    CCCC
    4 2 1 0
    DCCD
    
    예상 출력
    Case #1: YES
    Case #2: YES
    Case #3: NO
    
  2. 예제 2

    입력
    2
    12 4 2 2
    CDCCCDCCDCDC
    8 2 1 3
    DCCCCCDC
    
    예상 출력
    Case #1: YES
    Case #2: NO