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
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>

using namespace std;
typedef long long int llint;

/*

4 3
3 10 11 23
4 2 5

*/

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

	for(int i=0;i<m;++i)
	{
		llint d;
		cin>>d;

		llint prevt=0;
		llint wait_time=0;
		for(int j=0;j<n;++j)
		{
			const llint wait_time_customer=prevt+d-t[j];
			if(wait_time_customer>=0)
			{
				wait_time+=wait_time_customer;
				prevt=t[j]+wait_time_customer;
			}
			else
				prevt=t[j];
		}
		cout<<wait_time<<endl;
	}

	return 0;
}