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
#include <cstdio>
#include <vector>
using namespace std;
#define ll long long

int main()
{
   ll n, m, in, di;
   vector<ll> clients;
   scanf("%lld %lld", &n, &m);
   for(int i=0; i<n; i++)
   {
     scanf("%lld", &in);
     clients.push_back(in);
   }
   for(int i=0; i<m; i++)
   {
     ll possMoment = 0;
     ll sum = 0;
     scanf("%lld", &di);
     for(int j=0; j<n; j++)
     {
        if(clients[j]-possMoment>di)
           possMoment = clients[j];
        else
        {
           ll bonus = clients[j] - possMoment;
           ll res = di - bonus;
           sum += res;
           possMoment += di;
        }
     }
     printf("%lld\n", sum);
   }
   return 0;
}