Nội dung Bài tập
Mã:
ABC171.BaiD
Tên:
ABC171.BaiD
Dạng thi:
oi
Thang điểm:
100 điểm
Giới hạn thời gian:
1 giây
Giới hạn bộ nhớ:
256 MB
Được tạo bởi:
admin

Problem Statement

You have a sequence A composed of N positive integers: A1,A2,,AN.

You will now successively do the following Q operations:

  • In the i-th operation, you replace every element whose value is Bi with Ci.

For each i (1iQ), find Si: the sum of all elements in A just after the i-th operation.

Constraints

  • All values in input are integers.
  • 1N,Q,Ai,Bi,Ci105
  • BiCi

Input

Input is given from Standard Input in the following format:

N
A1 A2  AN
Q
B1 C1
    Quảng cáo 

       Ngôn ngữ : 

       Theme : 
Mời bạn soạn code



		



      Ai có thể xem bài này : 

Thông tin



Phần thảo luận