func_code_string: #include <bits/stdc++.h>   using namespace std;   int n;   long long dp[4];   int a[100005];   string s;   int main() {     cin >> n;     cin >> s;     for (int i = 0; i < n; i++) {       cin >> a[i];       if (s[i] ==  h )         dp[0] += a[i];       else if (s[i] ==  a )         dp[1] = min(dp[0], dp[1] + a[i]);       else if (s[i] ==  r )         dp[2] = min(dp[1], dp[2] + a[i]);       else if (s[i] ==  d )         dp[3] = min(dp[2], dp[3] + a[i]);     }     cout << dp[3];     return 0;   }   