------
## 最终结论
```python
def min_cost_to_delete(s, cost):
    total_cost = 0
    n = len(s)
    
    i = 0
    while i < n:
        current_group_cost = cost[i]
        max_cost = cost[i]
        
        j = i + 1
        while j < n and s[j] == s[i]:
            current_group_cost += cost[j]
            max_cost = max(max_cost, cost[j])
            j += 1
        
        total_cost += current_group_cost - max_cost
        i = j
    
    return total_cost

# Example usage:
print(min_cost_to_delete("abaac", [1,2,3,4,5]))  # Output: 3
print(min_cost_to_delete("abc", [1,2,3]))        # Output: 0
print(min_cost_to_delete("aabaa", [1,2,3,4,1]))  # Output: 2
```