//
// zap.cpp
//
//
// Created by Michał Buda on 22.11.2017.
//
#include <stdio.h>
#include <algorithm>
int main() {
int n, m;
scanf("%i", &n);
scanf("%i", &m);
long long* ct = new long long[n]; // client arrive time
long long bg; // begin time on i machine
long long en; // end time on i machine
int mt; // execution time on i machine
long long result; // result on i machine
for(int k = 0; k < n; ++k) {
scanf("%lli", &ct[k]);
}
for(int i = 0; i < m; ++i) {
bg = 0;
en = 0;
result = 0;
scanf("%i", &mt);
for(int k = 0; k < n; ++k) {
bg = std::max(ct[k] - mt, en);
en = bg + mt;
result += en - ct[k];
}
printf("%lli\n", result);
}
delete [] ct;
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 43 44 | // // zap.cpp // // // Created by Michał Buda on 22.11.2017. // #include <stdio.h> #include <algorithm> int main() { int n, m; scanf("%i", &n); scanf("%i", &m); long long* ct = new long long[n]; // client arrive time long long bg; // begin time on i machine long long en; // end time on i machine int mt; // execution time on i machine long long result; // result on i machine for(int k = 0; k < n; ++k) { scanf("%lli", &ct[k]); } for(int i = 0; i < m; ++i) { bg = 0; en = 0; result = 0; scanf("%i", &mt); for(int k = 0; k < n; ++k) { bg = std::max(ct[k] - mt, en); en = bg + mt; result += en - ct[k]; } printf("%lli\n", result); } delete [] ct; return 0; } |
English