func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m;   int check(vector<long long> &a, long long q) {     multiset<long long> s;     for (int j = 0; j < n; ++j) {       if (q + a[j] >= 0) {         q += a[j];         s.insert(a[j]);       } else if (a[j] > (*s.begin())) {         q += (a[j] - (*s.begin()));         s.erase(s.begin());         s.insert(a[j]);       }     }     return s.size();   }   int main() {     ios::sync_with_stdio(false);     cin >> n >> m;     vector<pair<long long, int> > b(m);     vector<int> out(m);     vector<long long> a(n);     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     for (int i = 0; i < m; ++i) {       cin >> b[i].first;       b[i].second = i;     }     sort(b.begin(), b.end());     int pre = -1, li = 0;     for (int i = 0; i <= n && pre != m - 1; ++i) {       int l = pre + 1, h = m - 1;       while (l < h) {         int md = (h + l) >> 1;         if (check(a, b[md].first) >= i) {           h = md;         } else {           l = md + 1;         }       }       if (check(a, b[l].first) != i) {         continue;       }       for (int j = pre + 1; j < l; ++j) {         out[b[j].second] = n - li;       }       li = i;       out[b[l].second] = n - i;       pre = l;     }     while (pre != m) {       out[b[pre++].second] = n - li;     }     for (int i = 0; i < m; ++i) {       cout << out[i] <<   n ;     }     return 0;   }   