#include<iostream> #include<vector> #include<deque> #include<algorithm> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int clients, ovens; cin >> clients >> ovens; vector<int> ovens_times; vector<unsigned long long> clients_times; ovens_times.reserve(ovens); clients_times.reserve(clients); while (clients--) { int t; cin >> t; clients_times.push_back(t); } while (ovens--) { int d; cin >> d; ovens_times.push_back(d); } for (const auto& d : ovens_times) { unsigned long long free_ts = 0; unsigned long long sum = 0; for (const auto& t : clients_times) { free_ts += d; if (t < free_ts) sum += (free_ts - t); free_ts = max(free_ts, t); } std::cout << sum << "\n"; } 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 31 32 33 34 35 36 37 38 39 40 41 | #include<iostream> #include<vector> #include<deque> #include<algorithm> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int clients, ovens; cin >> clients >> ovens; vector<int> ovens_times; vector<unsigned long long> clients_times; ovens_times.reserve(ovens); clients_times.reserve(clients); while (clients--) { int t; cin >> t; clients_times.push_back(t); } while (ovens--) { int d; cin >> d; ovens_times.push_back(d); } for (const auto& d : ovens_times) { unsigned long long free_ts = 0; unsigned long long sum = 0; for (const auto& t : clients_times) { free_ts += d; if (t < free_ts) sum += (free_ts - t); free_ts = max(free_ts, t); } std::cout << sum << "\n"; } return 0; } |