#include <cstdio> #include <vector> using namespace std; int main(){ int n, m; scanf("%d%d", &n, &m); vector<long long> piekarniki = vector<long long>(m); vector<long long> timer = vector<long long>(m, 0); vector<long long> oczekiwanie = vector<long long>(m, 0); vector<long long> klienci = vector<long long>(n); for(int i = 0; i < n; ++i){ scanf("%lld", &klienci[i]); } for(int i = 0; i < m; ++i){ scanf("%lld", &piekarniki[i]); } for(int i = 0; i < n; ++i){ for(int j = 0; j < m; ++j){ timer[j] += piekarniki[j]; if(timer[j] < klienci[i]) timer[j] = klienci[i]; else oczekiwanie[j] += timer[j]-klienci[i]; } } for(int i = 0; i < m; ++i){ printf("%lld\n", oczekiwanie[i]); } 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 42 | #include <cstdio> #include <vector> using namespace std; int main(){ int n, m; scanf("%d%d", &n, &m); vector<long long> piekarniki = vector<long long>(m); vector<long long> timer = vector<long long>(m, 0); vector<long long> oczekiwanie = vector<long long>(m, 0); vector<long long> klienci = vector<long long>(n); for(int i = 0; i < n; ++i){ scanf("%lld", &klienci[i]); } for(int i = 0; i < m; ++i){ scanf("%lld", &piekarniki[i]); } for(int i = 0; i < n; ++i){ for(int j = 0; j < m; ++j){ timer[j] += piekarniki[j]; if(timer[j] < klienci[i]) timer[j] = klienci[i]; else oczekiwanie[j] += timer[j]-klienci[i]; } } for(int i = 0; i < m; ++i){ printf("%lld\n", oczekiwanie[i]); } return 0; } |