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
#include <iostream>
#include <queue>
#include <assert.h>

using namespace std;


long max(long a, long b) {
	if (a > b) return a; else return b;
}


int main() {
	long n, m;
	cin >> n >> m;
	long t[n];   for (long i = 0; i<n; i++) cin >> t[i];
	long d[m];   for (long i = 0; i<m; i++) cin >> d[i];

	for (long j=0; j<m; j++) {
		long dd  = d[j];
		long pos = 0;
		long ret = 0;
		for (long i=0; i<n; i++) {
			if (pos + dd > t[i])
				ret += (pos + dd - t[i]);
			pos = max(pos+dd, t[i]);
		}
		cout << ret << endl;
	}
	return 0;
}