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 <algorithm>
#include <queue>

using namespace std;

#define NMAX 200000
#define MMAX 200000
#define TMAX 1000000000000ULL
#define DMAX 1000000

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    static ll t[NMAX];
    int n, m;

    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i) {
        scanf("%lld", t+i);
    }

    for (int i = 0; i < m; ++i) {
        int d;
        ll finish = 0, total_wait = 0;

        scanf("%d", &d);
        for (int i = 0; i < n; ++i) {
            finish = max(finish+d, t[i]);
            total_wait += finish-t[i];
        }
        printf("%llu\n", total_wait);
    }

    return 0;
}