CF431A.Black Square
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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?
就在不久前,一位非常聪明的学生 Jury 觉得上课很无聊,于是他在自己酷炫的触屏手机上下载了一款名为“黑方块”(Black Square)的游戏。
在这款游戏中,手机屏幕被划分为四个垂直的条带。每一秒,某些条带上会出现一个黑色方块。根据游戏规则,Jury 必须在这一秒内触摸对应的条带,才能使该方块消失。由于 Jury 既聪明又懒惰,他事先计算出:触摸第 i 个条带恰好会消耗 ai 卡路里。
现给定一个字符串 s,用于描述游戏过程,以及四个数字 a1,a2,a3,a4。请计算 Jury 消除所有方块总共需要消耗多少卡路里?
输入格式
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 ≤ 104).
The second line contains string s (1 ≤ |s| ≤ 105), 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.
第一行包含四个用空格分隔的整数 a1、a2、a3、a4(0 ≤ a1, a2, a3, a4 ≤ 104)。
第二行包含一个字符串 s(1 ≤ ∣s∣ ≤ 105),其中字符串的第 i 个字符为 "1" 表示游戏第 i 秒时方块出现在第一条轨道上,为 "2" 表示出现在第二条轨道上,为 "3" 表示出现在第三条轨道上,为 "4" 表示出现在第四条轨道上。
输出格式
Print a single integer — the total number of calories that Jury wastes.
输出一个整数—— Jury 浪费的总卡路里数。
输入输出样例
输入#1
1 2 3 4 123214
输出#1
13
输入#2
1 5 3 2 11221
输出#2
13
输入解题思路,AI测评打分。不知道怎么写?