eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Qurban 2011

Qurban 2011

Qurban is an Islamic practice that involves the sacrifice of certain livestock. Qurban is done only on the \textbf{10-13 }Zulhijjah, which is the last month in the Islamic calendar. Livestockto be slaughtered (and sacrificed) are limited to camels, cattle, buffaloes, sheep or goats. The meat from each slaughtered camel, cattle, or buffalo can be divided into \textbf{7} equal parts to be shared by \textbf{7} persons. Since goats and sheep are small in size compared to the other livestock, therefore one goat or sheep is equivalent to one part of the previous three previous livestock. A person can register to sacrifice more than one part. In order to get the correct number of livestock to be slaughtered, one has to ensure that all \textbf{7} parts is accounted for in order to slaughter one buffalo. If not, there will be a cost liability to the person incharged. In a situation when a person registers for more than \textbf{7} parts, for example \textbf{8} parts of a buffalo, the remainder of one part has to be combined with parts sacrificed by other persons. Normally, the buffaloesand sheep are supplied by farmer, and the location for slaughtering is done at different placesdepending on the customers. There is only one truck that can transport either the buffaloesor the sheep. The truck can transport a maximum of \textbf{3} buffaloesor 6 sheep at one time. Given a list of orders for qurban, calculate the minimum number of trip to transport the buffaloesand sheep to be slaughtered. \InputFile The input consists of a few lines of data. The first line is an integer \textbf{T}, which represents thenumber of test data. It is followed by \textbf{T} lines of data. Each of these lines begins with an integer \textbf{m}, which represents the number of order, followed by a single space and a set of orders. The orders are in the following format: two characters where the first is either character '\textbf{b}' (represents parts of a buffalo) or '\textbf{s}' (represents a sheep). This is followed by an integer that represents the number of orders for the respective parts of cow or sheep. Each order is separated by a single space. \OutputFile The output is the minimum number of trip to transport the buffaloesand sheep to be slaughtered.
Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
3
4 b3 s1 b9 b4
2 s3 b7
5 b1 b1 b2 b2 b1
Вихідні дані #1
2
2
1
Джерело ACM-ICPC Malaysia al-Khawārizmī Programming Contest 2011