A - Library Book Search Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 266

問題文

高橋君は大学図書館の司書です。この図書館には N 冊の本があり、それぞれの本 i1 \leq i \leq N)には「難易度」 P_i が設定されています。異なる本が同じ難易度を持つこともありますが、それらはそれぞれ別の本として扱います。

図書館では、学生の学習をサポートするために M 種類の「閲覧許可証」を発行しています。各閲覧許可証 j1 \leq j \leq M)には「許可レベル」 L_j が設定されており、この許可証を持つ学生は難易度が L_j 以下の本すべてを閲覧することができます。

ある日、青木君がこの図書館にやってきました。青木君は K 枚の閲覧許可証を持っており、その番号は T_1, T_2, \ldots, T_K です。

青木君は、持っているいずれかの閲覧許可証で閲覧できる本をすべて読みたいと考えています。すなわち、K 枚の閲覧許可証それぞれで閲覧できる本の集合の和集合に含まれる本が対象です。同一の本が複数の閲覧許可証によって閲覧可能であっても、その本は 1 冊として数えます。

青木君が閲覧できる本の難易度の総和を求めてください。

制約

  • 1 \leq N \leq 2 \times 10^5
  • 1 \leq M \leq 2 \times 10^5
  • 1 \leq K \leq M
  • 1 \leq P_i \leq 10^9 (1 \leq i \leq N)
  • 1 \leq L_j \leq 10^9 (1 \leq j \leq M)
  • 1 \leq T_k \leq M (1 \leq k \leq K)
  • T_1, T_2, \ldots, T_K はすべて異なる
  • 入力はすべて整数

入力

N M K
P_1 P_2 \ldots P_N
L_1 L_2 \ldots L_M
T_1 T_2 \ldots T_K
  • 1 行目には、本の冊数 N、閲覧許可証の種類数 M、青木君が持っている閲覧許可証の枚数 K がスペース区切りで与えられる。
  • 2 行目には、各本の難易度 P_1, P_2, \ldots, P_N がスペース区切りで与えられる。
  • 3 行目には、各閲覧許可証の許可レベル L_1, L_2, \ldots, L_M がスペース区切りで与えられる。
  • 4 行目には、青木君が持っている閲覧許可証の番号 T_1, T_2, \ldots, T_K がスペース区切りで与えられる。

出力

青木君が閲覧できる本の難易度の総和を整数として 1 行で出力せよ。


入力例 1

5 3 2
3 7 2 5 4
5 3 7
1 3

出力例 1

21

入力例 2

6 4 3
10 20 30 40 50 60
25 15 45 35
2 3 4

出力例 2

100

入力例 3

10 5 2
100 200 300 400 500 600 700 800 900 1000
150 350 550 750 950
3 5

出力例 3

4500

Score : 266 pts

Problem Statement

Takahashi is a librarian at a university library. The library has N books, and each book i (1 \leq i \leq N) has a "difficulty" P_i assigned to it. Different books may have the same difficulty, but they are treated as separate books.

To support students' learning, the library issues M types of "viewing permits." Each viewing permit j (1 \leq j \leq M) has a "permit level" L_j, and a student holding this permit can view all books with difficulty L_j or less.

One day, Aoki visits this library. Aoki holds K viewing permits, numbered T_1, T_2, \ldots, T_K.

Aoki wants to read all books that can be viewed with any of his viewing permits. That is, the target books are those in the union of the sets of books viewable by each of his K viewing permits. Even if the same book can be viewed by multiple viewing permits, it is counted as one book.

Find the sum of difficulties of all books that Aoki can view.

Constraints

  • 1 \leq N \leq 2 \times 10^5
  • 1 \leq M \leq 2 \times 10^5
  • 1 \leq K \leq M
  • 1 \leq P_i \leq 10^9 (1 \leq i \leq N)
  • 1 \leq L_j \leq 10^9 (1 \leq j \leq M)
  • 1 \leq T_k \leq M (1 \leq k \leq K)
  • T_1, T_2, \ldots, T_K are all distinct
  • All input values are integers

Input

N M K
P_1 P_2 \ldots P_N
L_1 L_2 \ldots L_M
T_1 T_2 \ldots T_K
  • The first line contains the number of books N, the number of types of viewing permits M, and the number of viewing permits Aoki holds K, separated by spaces.
  • The second line contains the difficulties of each book P_1, P_2, \ldots, P_N, separated by spaces.
  • The third line contains the permit levels of each viewing permit L_1, L_2, \ldots, L_M, separated by spaces.
  • The fourth line contains the numbers of the viewing permits Aoki holds T_1, T_2, \ldots, T_K, separated by spaces.

Output

Output the sum of difficulties of the books Aoki can view as an integer on a single line.


Sample Input 1

5 3 2
3 7 2 5 4
5 3 7
1 3

Sample Output 1

21

Sample Input 2

6 4 3
10 20 30 40 50 60
25 15 45 35
2 3 4

Sample Output 2

100

Sample Input 3

10 5 2
100 200 300 400 500 600 700 800 900 1000
150 350 550 750 950
3 5

Sample Output 3

4500