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

using std::cin;
using std::cout;
using std::max;
using std::vector;

int main() {
    cin.sync_with_stdio(false);
    cin.tie(nullptr);

    vector<long long> times;

    long long n, m;
    cin >> n >> m;
    times.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> times[i];
    }

    long long d, index, result;
    for (int j = 0; j < m; j++) {
        cin >> d;
        index = 0;
        result = 0;
        for (int i = 0; i < n; i++) {
            index = max(index + d, times[i]);
            result += index - times[i];
        }
        cout << result << '\n';
    }
}