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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int n, m;
long long int t[200001];
int d[200001];
long long int result;
long long int last;
long long int kli;

int main()
{
	
	scanf("%d%d", &n, &m);

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


	/*n = 200000;
	m = 100;
	d[0] = 1000000;*/



	for (int j = 0; j < m; ++j)
	{
		long long int czas_pieczenia = d[j];
		result = 0;
		last = 0;

		for (int i = 0; i < n; ++i)
		{
			kli = t[i];

			long long int newLast = max(kli + (last - kli) + czas_pieczenia, kli);
			long long int wait = newLast - kli;
			last = newLast;
			result += wait;
		}

        printf("%lld\n", result);

	}

	

    return 0;
}