A9559 | Black Square
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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?
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.
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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted