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
#include "iostream"
#include "cstdio"
#include <vector>
using namespace std;
int n, m, temp;
unsigned long long suma, co;
vector < int > piek;
vector < long long > czas;
int main()
{
	scanf("%d", &n);
	scanf("%d", &m);
	for (int i = 0; i < n; i++) {
		scanf("%d", &temp);
		czas.push_back(temp);
	}
	for (int i = 0; i < m; i++) {
		scanf("%d", &temp);
		piek.push_back(temp);
	}
	for (int i = 0; i < piek.size(); i++) {
		co = 0;
		suma = 0;
		for (int j = 0; j < czas.size(); j++) {
			if (piek[i] + co <= czas[j]) {
				co = czas[j];
			}
			else {
				suma += piek[i]-(czas[j]-co);
				co += piek[i];
			
			}
		}
		cout << suma << endl;
	}
	return 0;
}