102900: [Atcoder]ABC290 A - Contest Result

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:3 Solved:0

Description

Score : $100$ points

Problem Statement

There was a contest with $N$ problems. The $i$-th $(1\leq i\leq N)$ problem was worth $A_i$ points.

Snuke took part in this contest and solved $M$ problems: the $B_1$-th, $B_2$-th, $\ldots$, and $B_M$-th ones. Find his total score.

Here, the total score is defined as the sum of the points for the problems he solved.

Constraints

  • $1\leq M \leq N \leq 100$
  • $1\leq A_i \leq 100$
  • $1\leq B_1 < B_2 < \ldots < B_M \leq N$
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

$N$ $M$
$A_1$ $A_2$ $\dots$ $A_N$
$B_1$ $B_2$ $\dots$ $B_M$

Output

Print the answer as an integer.


Sample Input 1

3 2
10 20 30
1 3

Sample Output 1

40

Snuke solved the $1$-st and $3$-rd problems, which are worth $10$ and $20$ points, respectively. Thus, the total score is $10+30=40$ points.


Sample Input 2

4 1
1 1 1 100
4

Sample Output 2

100

Sample Input 3

8 4
22 75 26 45 72 81 47 29
4 6 7 8

Sample Output 3

202

Input

题意翻译

#### 题目描述 有一场比赛,第 $i$ 个问题的分数是 $A_i$。 Snuke 参加并解决了 $M$ 个问题,分别是第 $B_1\ B_2\ldots B_M$ 个问题。 输出他的总分数。 #### 输入格式 输入以以下格式: >$N$ $M$ > >$A_1\ A_2\ \ldots\ A_N$ > >$B_1\ B_2\ \ldots\ B_M$ #### 输出格式 输出答案。 #### 说明/提示 - $1\leq M\leq N \leq100$ - $1\leq A_i\leq 100$ - $1\leq B_1<B_2<\ldots<B_M\leq N$ - 输入的所有的数都是整数 #### 样例 $1$ 解释 Snuke 解决了第一个和第二个问题,分数分别是 $10$ 和 $30$,所以总分是 $10+30=40$。

Output

分数:100分 部分 部分 问题描述 有一个有N个问题的竞赛。第i个问题(1≤i≤N)值为Ai分。 Snuke参加了这个竞赛并解决了M个问题:第B1个,B2个,...,Bm个。 找出他的总分。 这里,总分定义为他解决的问题的点数之和。 部分 约束 1≤M≤N≤100 1≤Ai≤100 1≤B1

加入题单

算法标签: