1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	int t[n], d[m], c[m], t0=0;
	for (int i=0; i<n; i++) cin >> t[i];
	for (int i=0; i<m; i++) cin >> d[i];
	for (int i=0; i<m; i++){
		c[i]=0;
		t0=0;
		for (int j=0; j<n; j++){
			if (t0+d[i]>t[j]){
				t0+=d[i];
				c[i]+=(t0-t[j]);
			}
			else t0=t[j];
		}
		cout << c[i] << "\n";
	}
	return 0;
}