#include <iostream> #include <string> #include <stdio.h> using namespace std; int main() { const long tmax=200001; long k,m; //pom long nk,mp,d; //lklien,lpiekar long long ta,sumto,t[tmax];// czas aktualny, cin >> nk >> mp; for (k=1; k<=nk; ++k) cin >> t[k]; for (m=1; m<=mp; ++m) { cin >> d; ta=0; sumto=0; for (k=1; k<=nk; ++k) { if (ta+d <= t[k]) ta=t[k]; else { ta+=d; sumto+=(ta-t[k]); } //else } //k cout << sumto << endl; } }
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 | #include <iostream> #include <string> #include <stdio.h> using namespace std; int main() { const long tmax=200001; long k,m; //pom long nk,mp,d; //lklien,lpiekar long long ta,sumto,t[tmax];// czas aktualny, cin >> nk >> mp; for (k=1; k<=nk; ++k) cin >> t[k]; for (m=1; m<=mp; ++m) { cin >> d; ta=0; sumto=0; for (k=1; k<=nk; ++k) { if (ta+d <= t[k]) ta=t[k]; else { ta+=d; sumto+=(ta-t[k]); } //else } //k cout << sumto << endl; } } |