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
#include <bits/stdc++.h>
using namespace std;

const int R = 200001;

long long t[R];

int main()
{
	int n, m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%lld",&t[i]);
	while(m--)
	{
		int d;
		scanf("%d",&d);
		long long w = 0, akt = 0;
		for(int i=1;i<=n;++i)
		{
			akt = max(akt + d, t[i]);
			w += akt - t[i];
		}
		printf("%lld\n",w);
	}
	return 0;
}