func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<long long> dan, ans;   vector<pair<long long, long long> > check;   long long calc(long long st) {     multiset<long long> otr;     long long otv = 0;     for (long long i = 0; i < dan.size(); i++) {       st += dan[i];       if (dan[i] < 0) otr.insert(dan[i]);       if (st < 0) {         st -= *otr.begin();         otr.erase(otr.begin());         otv++;       }     }     return otv;   }   int main() {     long long n, m;     cin >> n >> m;     dan.resize(n);     ans.resize(m, -1);     check.resize(m, {0, 0});     for (long long i = 0; i < n; i++) {       cin >> dan[i];     }     for (long long i = 0; i < m; i++) {       cin >> check[i].first;       check[i].second = i + 1;     }     sort(check.begin(), check.end());     reverse(check.begin(), check.end());     long long l = 0;     while (l < m) {       long long l1 = l, r1 = m, mid, mida;       long long now;       if (ans[l1] != -1)         now = ans[l1];       else {         now = calc(check[l1].first);         ans[l1] = now;       }       while (l1 + 1 != r1) {         mid = (l1 + r1) / 2;         if (ans[mid] != -1)           mida = ans[mid];         else {           mida = calc(check[mid].first);           ans[mid] = mida;         }         if (mida > now) {           r1 = mid;         } else {           l1 = mid;         }       }       if (ans[l1] == -1) {         ans[l1] = calc(check[l1].first);       }       l = l1 + 1;     }     long long last = -1;     for (long long i = 0; i < m; i++) {       if (ans[i] != -1)         last = ans[i];       else         ans[i] = last;     }     for (long long i = 0; i < m; i++) {       swap(check[i].first, check[i].second);       check[i].second = ans[i];     }     sort(check.begin(), check.end());     for (long long i = 0; i < m; i++) {       cout << check[i].second <<   n ;     }   }   