CF431A.Black Square

普及/提高-

通过率:0%

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 aia_{i} calories on touching the ii -th strip.

You've got a string ss , describing the process of the game and numbers a1,a2,a3,a4a_{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 a1a_{1} , a2a_{2} , a3a_{3} , a4a_{4} ( 0<=a1,a2,a3,a4<=1040<=a_{1},a_{2},a_{3},a_{4}<=10^{4} ).

The second line contains string ss ( 1<=s<=1051<=|s|<=10^{5} ), where the іі -th character of the string equals "1", if on the ii -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
    
首页