302240: CF431A. Black Square
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Black Square
题意翻译
小 A 正在玩一个名叫 Black Square 的游戏,屏幕上有 $4$ 个垂直带,每隔一会儿就有黑方块出现。小 A 点击第 $i$ 个垂直带需要消耗 $a_i$ 卡路里。现在,给定 $a_1,a_2,a_3,a_4$ 和小 A 的点击序列 $s$,求小 A 消耗了多少卡路里。 数据范围: - $0\leqslant a_1,a_2,a_3,a_4\leqslant 10^4$。 - $1\leqslant |s|\leqslant 10^5$。 Translated & Fixed by Eason_AC 2018.9.19 (Fixed on 2022.2.3)题目描述
Quite recently, a very smart student named Jury decided that lectures are boring, so he downloaded a game called "Black Square" on his super cool touchscreen phone. In this game, the phone's screen is divided into four vertical strips. Each second, a black square appears on some of the strips. According to the rules of the game, Jury must use this second to touch the corresponding strip to make the square go away. As Jury is both smart and lazy, he counted that he wastes exactly $ a_{i} $ calories on touching the $ i $ -th strip. You've got a string $ s $ , describing the process of the game and numbers $ a_{1},a_{2},a_{3},a_{4} $ . Calculate how many calories Jury needs to destroy all the squares?输入输出格式
输入格式
The first line contains four space-separated integers $ a_{1} $ , $ a_{2} $ , $ a_{3} $ , $ a_{4} $ ( $ 0<=a_{1},a_{2},a_{3},a_{4}<=10^{4} $ ). The second line contains string $ s $ ( $ 1<=|s|<=10^{5} $ ), where the $ і $ -th character of the string equals "1", if on the $ i $ -th second of the game the square appears on the first strip, "2", if it appears on the second strip, "3", if it appears on the third strip, "4", if it appears on the fourth strip.
输出格式
Print a single integer — the total number of calories that Jury wastes.
输入输出样例
输入样例 #1
1 2 3 4
123214
输出样例 #1
13
输入样例 #2
1 5 3 2
11221
输出样例 #2
13