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

int main() {
	std::ios::sync_with_stdio(false);
	int n, m;
	std::cin >> n >> m;
	std::vector<long long> t(n);
	for (auto&& value : t) {
		std::cin >> value;
	}
	while (m--) {
		int power;
		std::cin >> power;
		long long delay = 0, next = power;
		for (const auto& value : t) {
			if (next <= value) {
				next = value + power;
			} else {
				delay += next - value;
				next += power;
			}
		}
		std::cout << delay << '\n';
	}
	return 0;
}