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
#include <cstdio>
#include <vector>

using namespace std;

typedef long long unsigned int LL;
typedef vector<long long> vLL;
typedef vector<long long>::iterator vLLi;

int main()
{
LL N,M,n,m;
vLL T,D,S,T_max,K;

	scanf("%lld %lld",&N,&M);
		
	for (n = 0; n < N; n++)
	{
		scanf("%lld",&m);
		T.push_back(m); 
	}
	for (m = 0; m < M; m++)
	{
		scanf("%lld",&n);
		D.push_back(n);
		S.push_back(0);
		T_max.push_back(0);
	}
	
	for (n = 0; n < N; n++)
	{
		for (m = 0; m < M; m++)
		{
			if (T_max[m] + D[m] <= T[n]) T_max[m] = T[n];
			else 
			{
				T_max[m] += D[m];
				S[m] += T_max[m] - T[n];
			}
//			printf("%lld %lld %lld\n",T[n],T_max[m],S[m]);
		}
	}
	
	for (m = 0; m < M; m++)
	{
		printf("%lld\n",S[m]);
	}
		
	return 0;
}