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
#include <stdio.h>
#include <math.h>

using namespace std;

#define FOR0(i, n) for (int i = 0; i < n; i++)
#define FOR1(i, n) for (int i = 1; i < n; i++)
#define N (int)2e5
#define M N

int n, m, D[M];
long long T[N], W[M];

int main() {
	scanf("%d%d", &n, &m);
	FOR0(i, n) scanf("%lld", &T[i]);
	FOR0(i, m) scanf("%d", &D[i]);

	int d;
	long long time, w_time;

	FOR0(i, m) {
		d = D[i];
		w_time = 0;
		time = 0;
		FOR0(j, n) {
			if (T[j] - d < time) {
				w_time += time - (T[j] - d);
				time += d;
			}
			else time = T[j];
		}
		W[i] = w_time;
	}

	FOR0(i, m) printf("%lld\n", W[i]);

	return 0;
}