class Solution {
public:
int minCost(string s, vector<int>& cost) {
int ans = 0;
char pre = s[0];
int pre_id = 0;
for(int i=1; i<s.size(); ++i)
{
if(s[i]==pre)
{
if(cost[i]<cost[pre_id])
{
ans += cost[i];
}
else
{
ans += cost[pre_id];
pre = s[i];
pre_id = i;
}
}
else
{
pre = s[i];
pre_id = i;
}
}
return ans;
}
};