What Is in the Apple Box? Cash?
InterviewTime limit1sMemory limit1024 MB
Given apple and pear juice boxes with their sizes, compute the total mass of the boxes and the market value of the apples inside.
- Level
Easy2 of 10
- Topics
- Implementation, Math
- Solved
- No attempts yet
Problem
On a fresh day, Hey is chatting with Beusil over Calvados at a cafe.
Beusil: "We're so busy making a living that it's been ages since we last met..."
Hey: "Right. Prices have gone up so much lately, and it's hard to buy anything easily."
Beusil: "I went to the market yesterday and couldn't buy freely. Pears are expensive too, and apples cost won..."
Hey: "Oh! Speaking of apples, I was about to leave the house when..."
The topic is rising prices, where everything goes up except salaries...,
Above all, the box of Doo-Sik's father that held the 'apple box' and the pear juice boxes blocked the front door. Hey nearly got trapped inside and almost couldn't come to the cafe!!

Hey: "The 'Gunwi Yunha Apple' that Doo-Sik's father sent, the one that started opening a new horizon of apples no one can taste anywhere in the universe...
Thanks to its unusual growing method, each apple is a cube measuring in width, height, and length, with a constant mass of . The packaging is a specially made box with a mass of , so it ships safely.
Dad doesn't usually send much, even though he loves sending things. But the pear juice box that came with it was full of juice, and I have no idea where he bought it."
Hey explained the 'apple box' that had blocked the door in great detail. Beusil suddenly wondered how heavy the boxes blocking the door were.
Given the number and types of boxes and their sizes, calculate the mass of the boxes blocking the door.
The 'apple box' holds as many apples as possible, with the apples parallel to the sides of the box. Each pear juice box holds pear juices of each, regardless of its size. Ignore the mass of the boxes themselves.
Also, we cannot know how much cash was in the 'apple box'. Instead, for Hey, who loves cash, simply calculate the value of the apples at the market price of apples.
Input
The first line contains the number of boxes .
From the second line, lines follow, each describing one box. Each box is described by a character for its type, and three integers , , and for its width, height, and length. , , , and are separated by spaces.
consists only of A, which stands for apple, and B, which stands for pear.
, , and are integers in .
Output
On the first line, print the mass of the boxes blocking the door in .
On the second line, print the value of the apples in won, calculated simply at the market price of apples.
Hint
Doo-Sik's grandfather farms apples in Gunwi, and Yunha is his grandfather's name.
However, this has nothing to do with the 'Gunwi Yunha Apple' described in the problem.
Gunwi apples stimulate gastric juice secretion, which aids digestion, and they increase iron absorption. They also ease tension caused by stress, making them a beneficial fruit. They are grown on the slopes of Mount Palgong, which sits higher than the plains and has well-developed sandy soil. The climate is cooler than in other areas, so the flesh is firm, the juice is abundant, and the aroma is good.
-[Naver Knowledge Encyclopedia] Gunwi Apple-