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
35
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
using namespace std;

int main() {
    int n,m;
    long long sum_order = 0;
    long long t[200007];
    pair<long long, int> d[200007];
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> t[i];
        sum_order += t[i];
    }
    for (int j = 0; j < m; ++j) {
        long long duration;
        cin >> duration;
        long long prev = 0, sum_collect = 0;

        for (int i = 0; i < n; ++i) {
            long long current = prev + duration;
            if (current < t[i]) {
                current = t[i];
            }
            sum_collect += current;
            prev = current;
        }
        cout << sum_collect - sum_order << endl;
    }


    return 0;
}