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
40
#include <iostream>

typedef long long LL;

const int MAX = 200005;

unsigned n, m;

LL t[MAX];
//int d[MAX];

LL calc(unsigned n, LL d) {
    LL end = 0;
    LL result = 0;
    for (unsigned i = 0; i < n; i++) {
        if (t[i] >= end + d) {
            end = t[i];
        } else {
            result += end + d - t[i];
            end += d;
        }
//        std::cerr << end << std::endl;
//        std::cerr << result << std::endl;
    }
    return result;
}

int main() {
    scanf("%u", &n);
    scanf("%u", &m);
    LL input;
    for (unsigned i = 0; i < n; i++) {
        scanf("%lld", &t[i]);
    }
    LL d;
    for (unsigned i = 0; i < m; i++) {
        scanf("%lld", &d);
        printf("%lld\n", calc(n, d));
    }
}