Logo
(追記) (追記ここまで)

28593번 - Inflation 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 1024 MB60262347.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.

제한

  • 1ドル \leq N \leq 3 \cdot 10^5$.
  • 1ドル \leq p_i \leq 10^6$ (for each $i$ such that 1ドル \leq i \leq N$).
  • 1ドル \leq Q \leq 10^5$.
  • 1ドル \leq x,y \leq 10^6$ for all days.

Note: The answer may not fit in a 32ドル$-bit integer, so be aware of overflows if you are using C++.

서브태스크

번호배점제한
114

$N=1$

228

$N, Q, p_i, x, y \leq 100$

319

There are only INFLATION events

423

There are only SET events

516

No additional constraints

예제 입력 1

5
2 1 1 2 5
6
INFLATION 1
SET 3 2
SET 5 2
INFLATION 4
SET 6 1
SET 10 1

예제 출력 1

16
14
14
34
14
5

예제 입력 2

3
1 4 1
5
SET 1 1
SET 3 4
INFLATION 2
SET 3 1
SET 6 4

예제 출력 2

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번

  • 문제를 만든 사람: Isaac Chan

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /