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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>

using namespace std;

using int64 = long long;
constexpr auto TIMES_MAX = 200000;
int64 times[TIMES_MAX];
int64 D[TIMES_MAX];

int64 N,M;

int64 solution(int64 n, int64 d)
{
    int64 p = 0;
    int64 v = 0;

    for (int64 i = 0;i<n;i++){
        if (p + d > times[i]){
            v = v + p+d - times[i];
            p = p+d;
        }
        else {
            p = times[i];
        }
    }


    return v;
}

int main()
{
    scanf("%lld",&N);
    scanf("%lld",&M);


    for (int n=0;n<N;n++){
        int64 t;
        scanf("%lld", &t);

        times[n] = t;
    }

    for (int m=0;m<M;m++){
        int64 d;
        scanf("%lld", &d);

        D[m] = d;
    }
    for (int m=0;m<M;m++){
        cout << solution(N,D[m]) << endl;
    }
    return 0;
}