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 <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int MAX = 2*1e5 + 10;

ll a[MAX], b[MAX];

int main(){
    ios_base::sync_with_stdio(0);

    int n, m;
    cin >> n >> m;

    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < m; i++) cin >> b[i];

    ll odp = 0,  start;
    for(int i = 0; i < m; i++){
        odp = 0; start = 0;
        for(int j = 0; j < n; j++){
            start = max(start, a[j] - b[i]);
            odp += (b[i] + start -a[j]);
            start += b[i];
        }
        cout << odp << endl;
    }
}