LazyReplacment
CodeChefOpen on judge ↗
You have a sequence $A$ composed of $N$ positive integers:$A_{1}, A_{2}, \cdots, A_{N}$. You will now successively do the following $Q$ operations: - In the $i$-th operation, you replace every element whose value is $B_{i}$ with $C_{i}$. For each $i$ $(1 \leq i \leq Q)$, find $S_{i}$ : the sum of all elements in $A$ just after the $i$-th operation. ### Input $N$ $A_{1}$ $A_{2}$ $\cdots$ $A_{N}$
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start