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
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 200000;

long long d, o, t, T[MAXN];

int main() {
	int m, n;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; ++i) {
		scanf("%lld", T + i);
	}
	for (int i = 0; i < m; ++i) {
		scanf("%lld", &d);
		t = 0;
		o = 0;
		for (int j = 0; j < n; ++j) {
			if (t < T[j] - d + 1) {
				t = T[j];
			} else {
				o += t + d - T[j];
				t += d;
			}
		}
		printf("%lld\n", o);
	}
	return 0;
}