func_code_string: #include <bits/stdc++.h>   using namespace std;   int N, K;   int A[202020];   string S;   void solve() {     int i, j, k, l, r, x, y;     string s;     cin >> N >> K;     for (i = 0; i < (N); i++) cin >> A[i];     cin >> S;     signed long long ret = 0;     for (i = 0; i < N;) {       j = i;       vector<int> V;       while (j < N && S[i] == S[j]) {         V.push_back(A[j]);         j++;       }       i = j;       sort((V.begin()), (V.end()));       reverse((V.begin()), (V.end()));       for (j = 0; j < (min(K, (int)V.size())); j++) ret += V[j];     }     cout << ret << endl;   }   int main(int argc, char** argv) {     string s;     int i;     if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);     for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s +=   n ;     for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);     cout.tie(0);     solve();     return 0;   }   