시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 (추가 시간 없음) | 1024 MB | 160 | 75 | 70 | 51.095% |
John is a student working as a part-time barista at the micro kitchen of his school department. He operates the espresso machine at the kitchen to make espresso and latte for students seeking energy to study.
Today, there are n students coming to the micro kitchen to place an order. An order is noted with an espresso shot number x ranging between 1 and 4, and an optional letter L
that indicates that the student wants to have a x-shot latte. For example, an order 2
means a 2-shot espresso, and an order 3L
means a 3-shot latte.
Making an x-shot espresso consumes x ounces of water. Making a latte requires steaming milk and consumes one additional ounce of water, e.g. making a 3-shot latte consumes 4 ounces of water. The espresso machine at the micro kitchen has a water tank of s ounces that is full at the beginning of the day. John refills the water tank to s ounces whenever the remaining water in the tank is not enough to fulfill the next student’s order. John fulfills the n orders one by one without changing their order.
How many times do John have to refill the water tank today in order to serve all the n students?
The first line of input has two integers n (1 ≤ n ≤ 100) and s (10 ≤ s ≤ 200). The next n lines each contain a digit between 1 and 4 followed by an optional letter L
to describe an order. The orders are to be fulfilled in the given order as they appear in the input.
Output the number of times John has to refill the water tank of the espresso machine.
8 10 1 2L 3 4 3L 1 1L 4L
2
3 12 4 4 4
0
ICPC > Regionals > North America > Mid-Atlantic Regional > 2021 Mid-Atlantic USA Regional Contest A번
ICPC > Regionals > North America > North Central North America Regional > 2021 North Central NA Regional Contest L번