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
45
46
47
48
49
#include <iostream>

using namespace std;

int main()
{    
    int64_t n;
    int64_t m;
    cin >> n;
    cin >> m;

    int64_t t[n];
    int64_t d[m];
    for (int64_t i = 0; i < n; i++)
      {
          cin >> t[i];
      }
    for (int64_t i = 0; i < m; i++)
      {
          cin >> d[i];
      }

    int64_t czas;
    int64_t suma;
    int64_t czekanie;


    for (int64_t i = 0; i < m; i++)
    {
        czas = 0;
        suma = 0;
        for (int64_t j = 0; j < n; j++)
        {
            if ((t[j]-czas) >= d[i])
            {
                czas = t[j];
            }
            else
            {
                czas = czas + d[i];
            }
            czekanie = czas - t[j];
            suma += czekanie;
        }
        cout << suma << endl;
    }

    return 0;
}