P26369 [AtCoder] Contest
提高-
题目描述

Problem Description

A rabbit participated in a programming contest where $N$ problems were posed and solved $M$ problems correctly.

The rabbit decided to calculate its score from the points assigned to each problem and the list of problems it solved correctly.

Input Format

The input is given from the standard input in the following format:

$N$ $M$ $P_1$ $P_2$ ... $P_N$ $S_1$ $S_2$ ... $S_M$

  • The first line contains the integer $N$ $(1 ≦ N ≦ 100)$, representing the number of problems posed in the contest, and the integer $M$ $(1 ≦ M ≦ 100)$, representing the number of problems the rabbit solved correctly, separated by spaces.
  • The second line contains $N$ integers separated by spaces, representing the points assigned to each problem. The $i$-th integer $P_i$ $(1 ≦ P_i ≦ 100)$ represents the points obtained for solving the $i$-th problem correctly.
  • The third line contains $M$ integers separated by spaces, representing the information about the problems the rabbit solved correctly. The $i$-th integer $S_i$ $(1 ≦ S_i ≦ N)$ indicates that the rabbit solved the $S_i$-th problem correctly. It is guaranteed that $S$ is sorted in ascending order, i.e., for all $i, j$ $(i < j)$, $S_i < S_j$ holds.

Output Format

Output the total score of the rabbit in one line.

Sample Input and Output

Sample Input #1

5 3
100 1 20 14 50
1 2 5

Sample Output #1

151

Sample Input #2

8 8
100 100 100 100 100 100 100 100
1 2 3 4 5 6 7 8

Sample Output #2

800

Notes/Hints

Sample Explanation 1

In this input example, the rabbit solved problems $1$, $2$, and $5$ correctly. The points for problem $1$ are $100$, for problem $2$ are $1$, and for problem $5$ are $50$, so the total score is $151$.

Sample Explanation 2

In this input example, the rabbit solved all the problems correctly.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 3 100 1 20 14 50 1 2 5
样例输出
151