func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long maxn = 1e6 + 5, mod = 1e9 + 7, inf = 1e18;   long long n, q, a[maxn], mx[2ll][maxn];   pair<long long, long long> dp[2ll][maxn];   void cal_mx0(long long x) {     long long l = n - 1ll, sum = a[n];     for (long long i = n; i > 0; i--) {       if (l == 0) {         mx[0][i] = 1;         sum -= a[i];         continue;       }       while ((l > 0) && (sum + a[l] <= x)) {         sum += a[l];         l--;       }       mx[0][i] = l + 1ll;       sum -= a[i];     }   }   void cal_mx1(long long x) {     long long r = 2ll, sum = a[1];     for (long long i = 1; i <= n; i++) {       if (r == n + 1ll) {         mx[1][i] = n;         sum -= a[i];         continue;       }       while ((r <= n) && (sum + a[r] <= x)) {         sum += a[r];         r++;       }       mx[1][i] = r - 1ll;       sum -= a[i];     }   }   void cal_dp0() {     long long sum = 0;     for (long long i = 1; i <= n; i++) {       sum += a[i];       if (mx[0][i] == 1) {         dp[0][i] = {1, sum};         continue;       }       dp[0][i].first = dp[0][mx[0][i] - 1ll].first + 1ll;       dp[0][i].second = dp[0][mx[0][i] - 1ll].second;     }   }   void cal_dp1() {     long long sum = 0;     for (long long i = n; i > 0; i--) {       sum += a[i];       if (mx[1][i] == n) {         dp[1][i] = {1, sum};         continue;       }       dp[1][i].first = dp[1][mx[1][i] + 1ll].first + 1ll;       dp[1][i].second = dp[1][mx[1][i] + 1ll].second;     }   }   int main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n >> q;     long long second = 0;     for (long long i = 1; i <= n; i++) {       cin >> a[i];       second += a[i];     }     a[n + 1ll] = inf;     a[0] = inf;     while (q--) {       long long x;       cin >> x;       if (x >= second) {         cout << 1 <<   n ;         continue;       }       cal_mx0(x);       cal_mx1(x);       cal_dp0();       cal_dp1();       long long ans = min(dp[0][n].first, dp[1][1].first);       for (long long i = 1; i < n; i++) {         long long z = 0;         if ((dp[0][i].second + dp[1][i + 1ll].second) <= x) z = 1ll;         ans = min(ans, dp[0][i].first + dp[1ll][i + 1ll].first - z);       }       cout << ans <<   n ;     }   }   