#include <vector> #include <algorithm> #include <iostream> std::vector<long long> timers; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); long long k, p, t; std::cin >> k; std::cin >> p; timers.resize(k); for (long long i = 0; i < k; ++i) { std::cin >> timers[i]; } long long end = 0; long long sum = 0; for (long long i = 0; i < p; ++i) { std::cin >> t; for (long long time = 0; time < k; ++time) { end = std::max(end + t, timers[time]); sum += end - timers[time]; } std::cout << sum << '\n'; sum = 0; end = 0; } return 0; }
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 | #include <vector> #include <algorithm> #include <iostream> std::vector<long long> timers; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); long long k, p, t; std::cin >> k; std::cin >> p; timers.resize(k); for (long long i = 0; i < k; ++i) { std::cin >> timers[i]; } long long end = 0; long long sum = 0; for (long long i = 0; i < p; ++i) { std::cin >> t; for (long long time = 0; time < k; ++time) { end = std::max(end + t, timers[time]); sum += end - timers[time]; } std::cout << sum << '\n'; sum = 0; end = 0; } return 0; } |