1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <cstdio>
typedef int I;
typedef long long L;

static const I S = 200000;
static L ctab[S];
static I ptab[S];
static L rtab[S];

static void calc(const I M, const I N) {
        for (I m=0; m<M; ++m) {
                const I pt = ptab[m];
                L ret = 0;
                L t0 = 0;
                for (I n=0; n<N; ++n) {
                        L t = ctab[n];
                        if (t0 + pt > t) {
                                t0 += pt;
                                ret += t0 - t;
                        } else {
                                t0 = t;
                        }
                }
                rtab[m] = ret;
        }
}

int main() {
        I m, n;
        scanf("%d %d\n", &n, &m);
        for (I i=0; i<n; ++i)
                scanf("%lld", &ctab[i]);
        for (I i=0; i<m; ++i)
                scanf("%d", &ptab[i]);
        calc(m, n);
        for (I i=0; i<m; ++i)
                printf("%lld\n", rtab[i]);
        return 0;
}