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
#include <cstdio>
#include <vector>
using namespace std;

typedef long long LL;

vector<LL> times;

void solve(int x) {
    LL cur = 0, frame;
    LL delay = 0;
    for (auto it = times.begin(); it != times.end(); it++) {
        frame = *it - cur;
        if (x - frame > 0) {
            delay += x - frame;
            cur = *it + x - frame;
        } else {
            cur = *it;
        }
    }
    printf("%lld\n", delay);
}

int main() {
    int n, m, x;
    scanf("%d %d", &n, &m);
    times.reserve(n);
    LL t;
    for (int i = 0; i < n; ++i) {
        scanf("%lld", &t);
        times.push_back(t);
    }
    for (int i = 0; i < m; ++i) {
        scanf("%d", &x);
        solve(x);
    }
    return 0;
}