#P9463. [EGOI 2023] Inflation / 通货膨胀
[EGOI 2023] Inflation / 通货膨胀
Background
Day 1 Problem A.
The statement is translated from EGOI2023 inflation.
Problem Description
As everyone knows, people in southern Sweden often eat salad sandwiches. The prices of salad sandwiches change a lot, and the best way to analyze the economy is to go to the same salad sandwich shop every day and add up all prices on the menu.
A salad sandwich shop has different items on its menu. The -th item has price .
Each day, one of the following events happens:
INFLATION x: All prices increase by .SET x y: The price of every item whose price is is changed to .
Your task is to process days, and after the end of each day, output the total price of all items.
Input Format
The first line contains an integer , the number of items.
The second line contains integers .
The third line contains an integer , the number of days.
The next lines each contain a string and one or two integers.
If is INFLATION, then it is followed by one integer , meaning that all prices increase by on that day.
If is SET, then it is followed by two integers , meaning that the price of every item whose price is is changed to .
Output Format
Output lines. Each line should contain the total price of all items after the end of that day.
5
2 1 1 2 5
6
INFLATION 1
SET 3 2
SET 5 2
INFLATION 4
SET 6 1
SET 10 1
16
14
14
34
14
5
3
1 4 1
5
SET 1 1
SET 3 4
INFLATION 2
SET 3 1
SET 6 4
6
6
12
8
6
Hint
Sample Explanation
The figure below shows the first two days of sample . Note that after the end of day 1, the total sum of prices is , so the first output integer is .

Constraints
For all testdata, , , , .
- Subtask 1 ( points): .
- Subtask 2 ( points): , depends on Subtask 1.
- Subtask 3 ( points): Only
INFLATIONevents. - Subtask 4 ( points): Only
SETevents. - Subtask 5 ( points): No special constraints, depends on Subtasks 2, 3, and 4.
Hint
The answer may not fit in a 32-bit integer. If you use C++, be careful about possible overflow.
Translated by ChatGPT 5
