Problem I
Moving Porcelain
You have just started your bachelor’s degree and was lucky enough to get an apartment in some student housing not far from the university.
Today you’re moving your large collection of porcelain which
you’re very protective of. You have
Your parents insist on helping with the move, but you’ve
been hesitant to let them carry your porcelain, because your
mom is notoriously clumsy. Despite her best efforts, she will
drop some of the moving boxes, which will break the same
amount,
For good reason, you are worried about your porcelain collection. That is why you once in a while check the contents of a moving box and count the number of pieces.
Input
The first line of input contains two integers
The second line will have
The next
-
Repacking: A line will begin with an integer, if you repack your porcelain. The first integer
, defines how many boxes you’ve initially packed your porcelain into with . This is followed by integers, where defines how many different types of porcelain you’ve been able to fit in the box with .
The sum of the integers will always be equal to .
The third line of input will always be of this type. -
WHAM: A line will begin with a WHAM if your mom drops a box. The line ends with two integers
and . The first integer defines that your mom was carrying the box (the boxes are 0-indexed, because you’re a nerd). The second integer defines how many pieces of porcelain are broken of each type. It is guaranteed that your mom never breaks all or more pieces of one type of porcelain, for all porcelain in the dropped box. -
Mom?: A line will begin with Mom? followed by an integer
, if you want your mom to open the box, so you can count the amount of porcelain pieces in it.
Output
For each ‘Mom?
Sample 1 walkthrough
The first line of input defines that you have
The third line describes that you’ve packed it all into
-
the
box has the first three types of porcelain ( pieces in total) -
the
box has the next two types of porcelain ( pieces in total) -
the
box has the next type of porcelain ( pieces in total) -
the
and last box has the last two types of porcelain ( pieces in total)
On the fourth line of input, your mom breaks box
Sixth line of input is a ‘Mom? j’ query, so you will have to report back how many pieces of porcelain that are in the 1st box. This is 17.
Seventh line of input is also a ‘Mom? j’ query, so you will have to report back how many pieces of porcelain that are in the 0th box. This is 33.
Scoring
Group |
Points |
Limits |
Constraints |
|
|
|
None |
|
|
|
No WHAM queries |
|
|
|
None |
Sample Input 1 | Sample Output 1 |
---|---|
8 5 9 1 23 10 17 10 23 5 4 3 2 1 2 WHAM 1 5 4 3 2 1 2 Mom? 1 Mom? 0 |
17 33 |