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
#include<iostream>
using namespace std;
long long t[200001];
int d[200001];
int main()
{
	int n, m, i, p, suma;
	cin >> n >> m;
	for (int a = 1; a <= n; a++)
		cin >> t[a];
	for (int a = 1; a <= m; a++)
	{
		cin >> d[a];
		i = 0;
		p = d[a];
		suma = 0;
		for (int b = 1; b <= n; b++)
		{
			if (i + p > t[b])
			{
				suma += p + i - t[b];
				i = i + p;
			}
			else
				i = t[b];
		}
		cout << suma << "\n";
	}
	//cin >> n;
	return 0;
}