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
#include <iostream>
using namespace std;
int main() {
    int numberOfClients, numberOfCookers;
    long long *clientMoments, momentInTime = 0, requiredTime = 0;
    int *cookerDuration;
    
    cin >> numberOfClients >> numberOfCookers;
    
    clientMoments = new long long[numberOfClients];
    cookerDuration = new int[numberOfCookers];
    
    for (long long i = 0; i < numberOfClients ; i++) {
        cin >> clientMoments[i];
    }
    
    for (long long i = 0; i < numberOfCookers ; i++) {
        cin >> cookerDuration[i];
    }
    
    for (long long i = 0; i < numberOfCookers ; i++) {
        momentInTime = 0;
        requiredTime = 0;
        for (long long j = 0; j < numberOfClients ; j++) {
            momentInTime += cookerDuration[i];
            if(momentInTime > clientMoments[j])
            {
                requiredTime += (momentInTime - clientMoments[j]);
            } else {
                momentInTime = clientMoments[j];
            }
        }
        cout << requiredTime << endl;
    }
    return 0;
}