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
36
37
38
39
40
41
42
43
44
#include <iostream>
#include <vector>


using namespace std;

int main() {

    int n, m;

    cin >> n >> m;
    vector<int> customers_time, cooker_time, cooker_wait;

    for (int count = 0; count < n; count++) {
        int temp;
        cin >> temp;
        customers_time.push_back(temp);
    }
    for (int count = 0; count < m; count++) {
        int temp;
        cin >> temp;
        cooker_time.push_back(temp);
        cooker_wait.push_back(0);
    }

    for (int count = 0; count < cooker_time.size(); count++) {
        int last = 0;
        for (int count2 = 0; count2 < customers_time.size(); count2++) {
            if (customers_time[count2] - cooker_time[count] < last) {
                last += cooker_time[count];
                cooker_wait[count] += (last - customers_time[count2]);
                //cout << "diff " << last - customers_time[count2] <<'\n';
            } else last = customers_time[count2];
            //cout << "last " << last <<'\n';
        }

    }

    for (int count = 0; count < cooker_wait.size(); count++) {
        cout << cooker_wait[count] << '\n';
    }

    return 0;
}