| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 3 초 | 1024 MB | 60 | 26 | 23 | 47.917% |
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 $N$ different dishes on their menu. The $i$th dish has price $p_i$.
Every day, one of the following events happen:
INFLATION x: The integer $x$ is added to all prices.SET x y: Every dish with price $x$ gets its price set to $y$.Your task is to process $Q$ days, and after each day print the sum of all prices $p_i$.
The first line contains one integer $N,ドル the number of dishes.
The second line contains $N$ integers $p_1, p_2, \ldots, p_N$.
The third line contains one integer $Q,ドル the number of days.
The following $Q$ lines each contain a string $s$ followed by either one or two integers.
If $s$ is INFLATION, then one integer $x$ follows. This means that $x$ is added to all prices on this day.
If $s$ is SET, then two integers $x$ and $y$ follow. This means that all dishes with price $x$ get their price set to $y$ on this day.
Print $Q$ lines, the sum of all prices $p_i$ after each day.
Note: The answer may not fit in a 32ドル$-bit integer, so be aware of overflows if you are using C++.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 14 | $N=1$ |
| 2 | 28 | $N, Q, p_i, x, y \leq 100$ |
| 3 | 19 | There are only |
| 4 | 23 | There are only |
| 5 | 16 | No additional constraints |
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
This figure corresponds to the first two days of sample 1ドル$. Note that the sum of prices after the first day is 16ドル,ドル so the first integer in the output is 16ドル$.
Olympiad > European Girls' Olympiad in Informatics > EGOI 2023 > Day 1 A번