[Home|Training|Problems|Contests|C Language] | [Login|Register] |
Problems Status Rank Statistics |
Problem B
CooTek's Food Corner
Time Limit: 1000ms
Memory Limit: 32768kb Description
The company of CooTek has a food corner called Aboundant Cuisine Market (ACM). Everyday CooTekers (people working at CooTek) bring all kinds of delicious food there and share with others. The problem is that it is difficult to make sure there is enough food in the ACM. So Carl, the Advanced Cook Manager, asks you to devise a small tool to help monitor the food deposition and consumption at the ACM. Every kind of food has an ID which is a positive integer, and a non-negative integer representing QUANTITY. Carl wants to know the total quantity of certain kinds of food, and in case some food is out of stock, he or someone else will go and buy some more.
Input
Every line of input contains a letter being either 'p', 'c', or 'q', and two integers, both less than 1,000,000.If the letter is 'p' (produce), then the first integer is the ID of the food produced by some CooTeker, and the second integer is the quantity of the production. If the letter is 'c' (consume), then the first integer is the ID of the food consumed by some CooTeker, and the second integer is the quantity of the consumption. If the letter is 'q' (query), then the two integers x, y define the range [x, y] of IDs of food, the quantity of which is supposed to be calculated. You should process to the End of File (EOF). Output
For every query, output the quantity of food lying in the range defined.
Sample Input
p 10 100 p 20 30 q 1 100 c 20 10 p 30 40 q 20 30 Sample Output
130 60 |