/
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 266 点
問題文
高橋君は農園で収穫された果物の出荷作業を担当しています。
農園では N 個の果物が収穫され、それぞれ 1 から N までの番号が付けられています。各果物 i (1 \leq i \leq N) には糖度 A_i が測定されており、この値が大きいほど甘くて美味しい果物です。
今回、傷がついてしまった果物が M 個見つかりました。傷のある果物の番号は B_1, B_2, \ldots, B_M として与えられます(順序に特別な意味はありません)。
通常、傷のある果物は規格外品として通常とは別のルートで出荷されます。しかし、糖度が K 以上(すなわち A_i \geq K)の果物は特別に高級品として扱われるため、傷があっても規格外品とはせず、通常の出荷ルートに含めることになりました。
まとめると、傷があり、かつ糖度が K 未満の果物が規格外品として出荷されます。
高橋君が最終的に規格外品として出荷すべき果物の個数と、それらの果物の糖度の合計を求めてください。
制約
- 1 \leq N \leq 2 \times 10^5
- 1 \leq M \leq N
- 1 \leq K \leq 10^9
- 1 \leq A_i \leq 10^9 (1 \leq i \leq N)
- 1 \leq B_j \leq N (1 \leq j \leq M)
- B_1, B_2, \ldots, B_M はすべて異なる
- 入力はすべて整数
入力
N M K A_1 A_2 \ldots A_N B_1 B_2 \ldots B_M
- 1 行目には、果物の総数を表す N 、傷のある果物の個数を表す M 、高級品として扱う基準となる糖度を表す K が、スペース区切りで与えられる。
- 2 行目には、各果物の糖度を表す A_1, A_2, \ldots, A_N が、スペース区切りで与えられる。
- A_i は果物 i の糖度を表す。
- 3 行目には、傷のある果物の番号を表す B_1, B_2, \ldots, B_M が、スペース区切りで与えられる。
- B_j は傷のある果物の番号を表す。
出力
規格外品として出荷すべき果物の個数と、それらの果物の糖度の合計を、スペース区切りで 1 行に出力せよ。
入力例 1
5 3 10 8 12 5 15 7 1 3 4
出力例 1
2 13
入力例 2
8 5 20 25 18 30 12 8 22 15 19 2 4 5 6 8
出力例 2
4 57
入力例 3
15 7 100 150 80 95 200 45 120 75 180 90 60 110 55 130 85 70 3 5 7 9 10 12 14
出力例 3
7 505
Score : 266 pts
Problem Statement
Takahashi is in charge of shipping fruits harvested at a farm.
N fruits have been harvested at the farm, each numbered from 1 to N. For each fruit i (1 \leq i \leq N), a sweetness level A_i has been measured; the higher this value, the sweeter and more delicious the fruit.
It was discovered that M fruits have bruises. The numbers of the bruised fruits are given as B_1, B_2, \ldots, B_M (the order has no special meaning).
Normally, bruised fruits are shipped as substandard products through a separate route from the regular one. However, fruits with a sweetness level of K or higher (i.e., A_i \geq K) are treated specially as premium products, so even if they have bruises, they are not classified as substandard and are included in the regular shipping route.
In summary, fruits that have bruises and have a sweetness level less than K are shipped as substandard products.
Find the number of fruits that Takahashi should ultimately ship as substandard products, and the total sweetness level of those fruits.
Constraints
- 1 \leq N \leq 2 \times 10^5
- 1 \leq M \leq N
- 1 \leq K \leq 10^9
- 1 \leq A_i \leq 10^9 (1 \leq i \leq N)
- 1 \leq B_j \leq N (1 \leq j \leq M)
- B_1, B_2, \ldots, B_M are all distinct
- All inputs are integers
Input
N M K A_1 A_2 \ldots A_N B_1 B_2 \ldots B_M
- The first line contains N representing the total number of fruits, M representing the number of bruised fruits, and K representing the sweetness threshold for premium classification, separated by spaces.
- The second line contains the sweetness levels of each fruit A_1, A_2, \ldots, A_N, separated by spaces.
- A_i represents the sweetness level of fruit i.
- The third line contains the numbers of the bruised fruits B_1, B_2, \ldots, B_M, separated by spaces.
- B_j represents the number of a bruised fruit.
Output
Print the number of fruits to be shipped as substandard products and the total sweetness level of those fruits, separated by a space, on a single line.
Sample Input 1
5 3 10 8 12 5 15 7 1 3 4
Sample Output 1
2 13
Sample Input 2
8 5 20 25 18 30 12 8 22 15 19 2 4 5 6 8
Sample Output 2
4 57
Sample Input 3
15 7 100 150 80 95 200 45 120 75 180 90 60 110 55 130 85 70 3 5 7 9 10 12 14
Sample Output 3
7 505