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 <bits/stdc++.h>
#define M 200010
#define N 1000010
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
int n,m,x;
long long t[M],last,d,res;

int main(){
    scanf("%d%d",&n,&m);
    for(int i=1; i<=n; i++){
        scanf("%lld",&t[i]);
    }
    while(m--){
        scanf("%d",&x);
        last=res=0;
        d=x;
        for(int i=1; i<=n; i++){
            if(last+d>t[i]){
                res+=last+d-t[i];
            }
            last=max(t[i],last+d);
        }
        printf("%lld\n",res);
    }
    return 0;
}