AtlassianOA #2
Flower Bouquets
估计中等可在线判题
考点(AI 标注)动规入门
In the row of flowers, 0 is a rose and 1 is a cosmos. Three consecutive roses 000 sell for p, and one rose and one cosmos adjacent as 01 or 10 sell for q. Each flower can be used at most once, some flowers may go unused, and removing flowers to splice together new adjacencies is not allowed.
输入格式
The first line contains p q, and the second line contains a binary string s. Original bounds: 1≤p,q≤1000, 1≤|s|≤100000.
输出格式
Output a single integer answer.
样例 1
输入:
2 3
0001000
输出:
5
样例 2
输入:
1 5
10
输出:
5
样例 3
输入:
9 1
000000
输出:
18
样例说明
The outputs of the three public examples are, in order: 5; 5; 18. Verified by independent enumeration or direct simulation.