func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     long long n, i, j, k, m, t, x, y, sum;     cin >> t;     while (t > 0) {       t = t - 1;       cin >> n >> k;       long long a[n], c[k];       for (i = 0; i < n; i++) {         cin >> a[i];       }       for (i = 0; i < k; i++) {         cin >> c[i];       }       sort(a, a + n);       sort(c, c + k);       sum = 0;       m = -1;       j = n - 1;       for (i = 0; i < k; i++) {         if (c[i] == 1) {           sum = sum + 2 * a[j];           m = i;         } else           sum = sum + a[j];         c[i] = c[i] - 1;         j = j - 1;       }       j = m + 1;       i = n - k - 1;       for (i = i; i >= 0; i = i - 1) {         while (c[j] > 1) {           c[j] = c[j] - 1;           i = i - 1;         }         sum = sum + a[i];         j = j + 1;       }       cout << sum <<   n ;     }     return 0;   }   