Dtw_

折叠代码块
 
#include <bits/stdc++.h>

using namespace std;

#define int long long

int T;
int n, m;
int a[200010], b[200010];

signed main() {
    scanf("%lld", &T);
    while (T--) {
        scanf("%lld%lld", &n, &m);
        for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
        for (int i = 1; i < n; ++i) scanf("%lld", &b[i]);

        int ans = 1 << 30, res = 0, cc = 0;
        for (int i = 1; i <= n; ++i) {
            ans = min(ans, res + max(0ll, m - cc + a[i] - 1) / a[i]);

            if (cc >= b[i]) cc -= b[i], ++res;
            else {
                res += (b[i] - cc) / a[i];
                cc = (b[i] - cc) % a[i];
                if (cc) ++res, cc = a[i] - cc;
                ++res; 
            }
        }

        printf("%lld\n", ans);
    }

    return 0;
}

posted @ 2025-05-06 14:25  VlexM4HK  阅读(29)  评论(0)    收藏  举报