Codeforces Round #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 ailiters.
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 xi liters of water to the pi-th vessel;
- Print the number of liters of water in the ki-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.
推荐阅读
-
Codeforces Round #264 (Div. 2)
-
Codeforces Round #281 (Div. 2)_html/css_WEB-ITnose
-
Codeforces Round #259 (Div. 2) A B C 三连发_html/css_WEB-ITnose
-
Codeforces Round #281 (Div. 2) (A、B、C、D题)_html/css_WEB-ITnose
-
Codeforces Round #222 (Div. 2)
-
Codeforces Round #435 (Div. 2)-B. Mahmoud and Ehab and the bipartiteness
-
Codeforces Round #279 (Div. 2) 解题报告_html/css_WEB-ITnose
-
Codeforces Round #340 (Div. 2)-E-XOR and Favorite Number(莫队)
-
Codeforces Round #482 (Div. 2) D. Kuro and GCD and XOR and SUM(数学+01字典树)(好题)
-
Codeforces Round #553 (Div. 2) B. Dima and a Bad XOR(异或+思维)