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>
#include <vector>

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	int n,m;
	cin >> n >> m;

	vector<long long> client(n);
	for(int i=0; i < n; ++i){
		cin >> client[i];
	}

	vector<int> oven(m);
	vector <long long> min_time(m);
	for(int i=0; i < m; ++i){
		cin >> oven[i];
		min_time[i] = 0;
	}

	for(int i=0; i < m; ++i){
        long long act_time=0;
        for(int j=0; j < n; ++j){
            act_time += oven[i];
            if(act_time > client[j])
                min_time[i] += act_time - client[j];
            else
                act_time = client[j];
        }
        cout << min_time[i] << "\n";
	}

    return 0;
}