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
#include "iostream"
int main(void) 
{
    int n, m, i, j, d;
    long long tmp, tmp2, t, sut, arr[200005], longzero;
    t = 0;
    d = 0;
    longzero = 0;
    std::cin >> n;
    std::cin >> m;
    tmp = 0;
    tmp2 = 0;
    for ( int i=0; i<n; ++i ){
	std::cin>>tmp;
	arr[i]=tmp-tmp2;
	tmp2=tmp;
    }
    for ( int i=0; i<m; ++i ){
	sut = 0;
	std::cin >> d;
	t = 0;
	for ( int j=0; j<n; ++j ){
	    t = std::max(longzero, t + d - arr[j]);
	    sut += t;
	}
	std::cout << sut << "\n";
    }
    return 0;
}