func_code_string: #include <bits/stdc++.h>   using namespace std;   inline int in() {     int x;     scanf( %d , &x);     return x;   }   const int N = 1e6 + 7;   int n, m, a[N], Q;   long long SUM, psr[N], psl[N];   int en[N], st[N];   pair<int, long long> dpl[N], dpr[N];   int solve(long long maax) {     if (maax >= SUM) return 1;     long long sum = 0, cur = 0;     for (int i = 0; i < n; i++) {       sum += a[i];       while (sum > maax) {         en[cur] = i - 1;         sum -= a[cur];         cur++;       }     }     while (cur < n) en[cur++] = n - 1;     sum = 0, cur = n - 1;     for (int i = n - 1; i >= 0; i--) {       sum += a[i];       while (sum > maax) {         st[cur] = i + 1;         sum -= a[cur];         cur--;       }     }     while (cur >= 0) st[cur--] = 0;     for (int i = 0; i < n; i++) {       if (st[i] == 0)         dpl[i] = {1, psl[i + 1]};       else         dpl[i] = dpl[st[i] - 1], dpl[i].first++;     }     for (int i = n - 1; i >= 0; --i) {       if (en[i] == n - 1)         dpr[i] = {1, psr[i]};       else         dpr[i] = dpr[en[i] + 1], dpr[i].first++;     }     int mn = dpr[0].first;     for (int i = 1; i < n; i++)       mn = min(mn, dpr[i].first + dpl[i - 1].first -                        ((dpr[i].second + dpl[i - 1].second) <= maax));     return mn;   }   int32_t main() {     n = in(), Q = in();     for (int i = 0; i < n; i++) {       a[i] = in();       SUM += a[i];       psl[i + 1] = a[i] + psl[i];     }     for (int i = n - 1; i >= 0; --i) psr[i] = psr[i + 1] + a[i];     while (Q--) {       long long x;       cin >> x;       cout << solve(x) <<   n ;     }   }   