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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include<stdio.h>
#include<iostream>
using namespace std; 



int main()
{
	cin.sync_with_stdio(false);
	long long clients; 
	cin >> clients;
	long long ovens;
	cin >> ovens; 
	
	long long* times = new long long[clients];
	long long* delays = new long long[ovens];
	
	
	for(int i = 0; i<clients; ++i){
		cin >> times[i];		
	}
	
	long long* spaces = new long long[clients];
	spaces[0] = times[0];
	long long minSpace = spaces[0];
	for(int client = 1; client<clients; ++client){
		spaces[client] = times[client] - times[client-1];
		if(spaces[client] < minSpace){
			minSpace = spaces[client];
		}
	}
	
	
	for(int i = 0; i<ovens; ++i){
		cin >> delays[i];
	}
	
	for(int i =0; i<ovens; ++i){
		long long delay = delays[i];
		if(delay < minSpace){
			cout << "0" << endl;
			continue;
		}
		long long waitingSum = 0; 
		long long currentAdditionalDelay = 0;
		for(int client = 0; client < clients; ++ client){
			long long waitingTime = delay - spaces[client] + currentAdditionalDelay;
			if(waitingTime > 0){
				waitingSum += waitingTime;
				currentAdditionalDelay = waitingTime;
			}else{
				currentAdditionalDelay = 0;
			}
		}
		cout << waitingSum << endl;
	}

	return 0;
}