func_code_string: #include <bits/stdc++.h>   using namespace std;   const int INF = 1e9;   long long n, m, b, ans;   long long a[1005];   int l, r, mid;   long long dp[1005][1005];   struct Node {     long long w, id;   } f[1005];   bool cmp(Node a, Node b) {     if (a.w != b.w) return a.w < b.w;     return a.id > b.id;   }   int main() {     cin >> n >> m;     for (int i = 1; i <= n; ++i) cin >> a[i];     for (int i = 1; i <= n + 1; ++i)       for (int j = 0; j <= n + 1; ++j) dp[i][j] = 1e18;     dp[n + 1][0] = 0;     for (int i = n; i >= 1; --i) {       for (int j = 0; j <= n; ++j)         dp[i][j] = min(dp[i][j], max(0LL, dp[i + 1][j] - a[i]));       for (int j = 1; j <= n; ++j) dp[i][j] = min(dp[i][j], dp[i + 1][j - 1]);     }     for (int i = 0; i <= n; ++i) {       f[i].w = dp[1][i];       f[i].id = i;     }     sort(f, f + n + 1, cmp);     for (int i = 1; i <= m; ++i) {       cin >> b;       l = 0;       r = n;       ans = -1;       while (l <= r) {         mid = (l + r) / 2;         if (f[mid].w <= b) {           ans = f[mid].id;           l = mid + 1;         } else           r = mid - 1;       }       cout << ans << endl;     }     return 0;   }   