好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

CodeforcesRound#218(Div.2)D.Vessels

There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n , in the order from the highest to the lowest, the volume of the i -th vessel is a i liters. Initial

There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n , in the order from the highest to the lowest, the volume of the i -th vessel is a i liters.

Initially, all the vessels are empty. In some vessels water is poured. All the water that overflows from the i -th vessel goes to the ( i  + 1) -th one. The liquid that overflows from the n -th vessel spills on the floor.

Your task is to simulate pouring water into the vessels. To do this, you will need to handle two types of queries:

Add x i liters of water to the p i -th vessel; Print the number of liters of water in the k i -th vessel.

When you reply to the second request you can assume that all the water poured up to this point, has already overflown between the vessels.

查看更多关于CodeforcesRound#218(Div.2)D.Vessels的详细内容...

  阅读:38次