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

#define LL long long
#define MAX_LENGTH 200010

using namespace std;

LL count_delay(int n, LL *t, int d) {
    LL now = 0, delay = 0, ready_time;
    for (int i = 0; i < n; i++) {
        ready_time = now + d;
        if (ready_time > t[i])
            delay += ready_time - t[i];
        else
            now = t[i];
    }
    return delay;
}

int main()
{
    int n, m, d;
    LL t[MAX_LENGTH];

    cin >> n >> m;

    for (int i = 0; i < n; i++)
        cin >> t[i];

    for (int i = 0; i < m; i++) {
        cin >> d;
        cout << count_delay(n, t, d) << endl;
    }

    return 0;
}