A - Warehouse Cargo Organization Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 266

問題文

高橋君は物流会社の倉庫で荷物の管理を担当しています。今日は N 個の荷物が入荷する予定でしたが、そのうち M 個の荷物は発送元でキャンセルされ、届かないことになりました。

倉庫では、各荷物に 1 から N までの管理番号が割り振られています。管理番号 i の荷物の重さは T_i グラムです(1 \leq i \leq N)。キャンセルされた M 個の荷物の管理番号は D_1, D_2, \ldots, D_M で与えられます。なお、同じ荷物が重複してキャンセルされることはありません。

高橋君は届いた荷物を棚に収納するため、重さを「ユニット」という単位に換算して記録することにしました。1 ユニットは K グラムに相当します。各荷物のユニット数は、その荷物の重さ(グラム)を K で割り小数点以下を切り捨てた値として定義します。すなわち、管理番号 i の荷物のユニット数は \lfloor T_i / K \rfloor です。

キャンセルされずに届いた荷物(管理番号が D_1, D_2, \ldots, D_M のいずれでもない荷物)のそれぞれについてユニット数を求め、それらの総和を出力してください。

制約

  • 1 \leq N \leq 2 \times 10^5
  • 0 \leq M \leq N
  • 1 \leq K \leq 10^9
  • 1 \leq T_i \leq 10^9 (1 \leq i \leq N)
  • 1 \leq D_j \leq N (1 \leq j \leq M)
  • D_1, D_2, \ldots, D_M はすべて異なる
  • 入力はすべて整数

入力

N M K
T_1 T_2 \cdots T_N
D_1 D_2 \cdots D_M
  • 1 行目には、入荷予定の荷物の個数 N、キャンセルされた荷物の個数 M1 ユニットに相当するグラム数 K が、スペース区切りで与えられる。
  • 2 行目には、管理番号 i の荷物の重さ(グラム)を表す T_i が、N 個スペース区切りで与えられる。
  • 3 行目には、キャンセルされた荷物の管理番号 D_j が、M 個スペース区切りで与えられる。ただし M = 0 のとき、3 行目は空行ではなく与えられない(入力は 2 行からなる)。

出力

キャンセルされずに届いた各荷物について \lfloor T_i / K \rfloor を求め、それらの総和を 1 行で出力してください。


入力例 1

5 2 3
10 7 8 5 6
2 4

出力例 1

7

入力例 2

4 1 5
3 12 7 20
3

出力例 2

6

入力例 3

10 3 100
250 99 450 1000 50 333 678 812 999 10
2 5 9

出力例 3

33

入力例 4

15 5 7
100 49 35 77 64 21 88 53 42 99 15 70 28 56 91
1 5 8 12 15

出力例 4

72

入力例 5

1 0 1000000000
999999999

出力例 5

0

Score : 266 pts

Problem Statement

Takahashi is in charge of managing packages at a logistics company's warehouse. Today, N packages were scheduled to arrive, but M of them were cancelled by the sender and will not be delivered.

In the warehouse, each package is assigned a management number from 1 to N. The weight of the package with management number i is T_i grams (1 \leq i \leq N). The management numbers of the M cancelled packages are given as D_1, D_2, \ldots, D_M. Note that the same package is never cancelled more than once.

To store the delivered packages on shelves, Takahashi decided to convert the weights into a unit called "units" and record them. 1 unit corresponds to K grams. The number of units for each package is defined as the weight (in grams) of that package divided by K, rounded down to the nearest integer. That is, the number of units for the package with management number i is \lfloor T_i / K \rfloor.

For each package that was not cancelled and actually arrived (i.e., packages whose management numbers are not any of D_1, D_2, \ldots, D_M), compute the number of units and output their total sum.

Constraints

  • 1 \leq N \leq 2 \times 10^5
  • 0 \leq M \leq N
  • 1 \leq K \leq 10^9
  • 1 \leq T_i \leq 10^9 (1 \leq i \leq N)
  • 1 \leq D_j \leq N (1 \leq j \leq M)
  • D_1, D_2, \ldots, D_M are all distinct
  • All input values are integers

Input

N M K
T_1 T_2 \cdots T_N
D_1 D_2 \cdots D_M
  • The first line contains the number of scheduled packages N, the number of cancelled packages M, and the number of grams per unit K, separated by spaces.
  • The second line contains N space-separated values T_i, representing the weight (in grams) of the package with management number i.
  • The third line contains M space-separated values D_j, representing the management numbers of the cancelled packages. However, when M = 0, the third line is not given (the input consists of only 2 lines).

Output

For each package that was not cancelled and actually arrived, compute \lfloor T_i / K \rfloor, and output their total sum on a single line.


Sample Input 1

5 2 3
10 7 8 5 6
2 4

Sample Output 1

7

Sample Input 2

4 1 5
3 12 7 20
3

Sample Output 2

6

Sample Input 3

10 3 100
250 99 450 1000 50 333 678 812 999 10
2 5 9

Sample Output 3

33

Sample Input 4

15 5 7
100 49 35 77 64 21 88 53 42 99 15 70 28 56 91
1 5 8 12 15

Sample Output 4

72

Sample Input 5

1 0 1000000000
999999999

Sample Output 5

0