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
#include <iostream>
const int C=200001;
using namespace std;
int main() {
	long long T[C];
	long long n,m,x;
	cin>>n;
	cin>>m;
	T[0]=0;
	for (int i=1;i<=n;i++){
		cin>>T[i];
 	}
	for (int j=0;j<m;j++){
		cin>>x;
		long long delay=x;
		long long suma=0;
		for (int i=1;i<=n;i++){
			long long sumap=delay-T[i];
			if (sumap<0) {
				delay=x+T[i];
			}
			else{
				delay=sumap+x+T[i];
				suma+=sumap;
			}
		}
		cout<<suma<<endl;
	}
	return 0;
}