BarclaysOA #2
Adjacent Tokens Scoring
简单可在线判题
考点(AI 标注)模拟/实现
A row has n cells; each cell has a value points[i], and its state is T if it holds a token or E if it is empty. Each T cell contributes its own value; each pair of adjacent T cells contributes an extra 1 point. Find the total score.
The rules, constraints, and two public examples correspond to the original Barclays problem.
输入格式
The first line contains n (1 ≤ n ≤ 100); the second line contains n integers points[i] (1 ≤ points[i] ≤ 1000); the third line contains a string of length n consisting only of E and T.
输出格式
Output a single integer, the answer.
样例 1
输入:
5
3 2 1 2 2
ETTTE
输出:
7
样例 2
输入:
4
2 2 2 2
TTTT
输出:
11
样例 3
输入:
5
3 4 5 2 3
TEETT
输出:
9
样例说明
In example 1 the tokens are in cells 0, 3, 4; the base score is 3+2+3=8, and the adjacent pair (3,4) adds 1, for a total of 9.