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 <cstdlib>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	int maxD = 0;

	long long a;
	vector<long long> tt(n), dd(m);
	for (int i = 0; i < n; i++)
	{
		scanf("%lld", &tt[i]);
	}
	
	for (int i = 0; i < m; i++)
	{
		scanf("%lld", &dd[i]);
		if (dd[i] > maxD)
			maxD = dd[i];
	}

//	cout << "MaxD = " << maxD << endl;

	long long delay, startAt, t, end;
	for (int i = 0; i < m; i++)
	{
		delay = 0;
		startAt = 0;
	//	cout << endl << "D= " << dd[i] << endl;
		for (int j= 0; j < n; j++)
		{
			t = tt[j];
		//	cout << "t: " << t << " delay: ";
				
			end = startAt + dd[i];

			if (end > t)
			{
			//	cout << (end - t) << " ";
				delay += (end - t);
				startAt = end;
			}
			else
			{
		//		cout << 0 << " ";
				startAt = t;
			}
		//	cout << endl;
		}
	//	cout << "Total delay: " << delay << endl;
		cout << delay << "\n";;
	}
    return 0;
}