Inflation
면접 대비시간 제한3초메모리 제한1024 MB
메뉴 가격들의 합을 유지하면서, 전체에 x를 더하거나 가격이 x인 모든 메뉴를 y로 바꾸는 연산을 처리한 뒤 매일 합을 출력한다.
문제
People in southern Sweden are known to eat falafel a lot. The price of falafel is highly volatile, and the best way to analyze the state of the economy is to go to the same falafel place every day and add up all the prices on their menu.
A falafel place has different dishes on their menu. The th dish has price .
Every day, one of the following events happen:
INFLATION x: The integer is added to all prices.SET x y: Every dish with price gets its price set to .
Your task is to process days, and after each day print the sum of all prices .
입력
The first line contains one integer , the number of dishes.
The second line contains integers .
The third line contains one integer , the number of days.
The following lines each contain a string followed by either one or two integers.
If is INFLATION, then one integer follows. This means that is added to all prices on this day.
If is SET, then two integers and follow. This means that all dishes with price get their price set to on this day.
출력
Print lines, the sum of all prices after each day.
제한
- .
- (for each such that ).
- .
- for all days.
Note: The answer may not fit in a -bit integer, so be aware of overflows if you are using C++.
힌트
This figure corresponds to the first two days of sample . Note that the sum of prices after the first day is , so the first integer in the output is .
