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
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;
long long people[300000];
int main() {
    
	int n,k;
    scanf("%d %d", &n, &k);
    
	for(int i=0; i<n; i++){
   	    scanf("%Ld",people+i);
	}
	for(int j=0; j<k; j++){
		int speed;
   	    scanf("%d", &speed);
   	    long long res=0;
   	    long long t=0;
   	    for(int i=0; i<n; i++){
            if (t+speed<=people[i]) {
            	t = people[i];
			} else {
				t+=speed;
				res+=(t-people[i]);
			}
		}
		cout<<res<<"\n";
	}

	return 0;
}