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
#include <bits/stdc++.h>
using namespace std;
const int arrs = 1e6+10;
typedef long long ll;



int n, m;
ll t[arrs];
ll c[arrs];


int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++i) {
		scanf("%lld", t+i);
	}
	for(int i = 1; i <= m; ++i) {
		scanf("%lld", c+i);
	}
	
	for(int i = 1; i <= m; ++i) {
		ll cur = 0;
		ll res = 0;
		for(int j = 1; j <= n; ++j) {
			cur += c[i];
			if(t[j] > cur) {
				cur = t[j];
			}
			else {
				res += cur-t[j];
			}
		}
		printf("%lld\n", res);
		
	}
}