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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifdef _MSC_VER
    #define _CRT_SECURE_NO_WARNINGS
#endif

#include <stdio.h>
#include <string.h>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

typedef long long int LL;

typedef std::vector<int> VI;
typedef std::vector<VI> VVI;
typedef std::vector<LL> VLL;
typedef std::vector<double> VD;
typedef std::pair<int, int> PII;
typedef std::vector<PII> VPII;

static const int INF = 1000000001;
static const double EPS = 10e-9;

#ifdef _MSC_VER
    #define VAR(v, n) auto v = (n)
#else
    #define VAR(v, n) __typeof__(n) v = (n)
#endif

#define FOR(i, b, e) for (int i = (b), _e = (e); i <= _e; ++i)
#define FORD(i, b, e) for (int i = (b), _e = (e); i >= _e; --i)
#define REP(i, n) for (int i = 0, _n = (n); i < _n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(c) static_cast<int>((c).size())
#define FOREACH(it, c) for (VAR(it, (c).begin()); it != (c).end(); ++it)
#define PF push_front
#define PB push_back
#define MP std::make_pair
#define ST first
#define ND second

#ifdef _MSC_VER
    #define MAXN 2000
#else
    #define MAXN 200000
#endif

int main(void)
{
    LL t[MAXN];
    int n = 0;
    int m = 0;

#ifdef _MSC_VER
    freopen("data.in", "rt", stdin);
#endif

    int ignored = scanf("%d %d", &n, &m);

    REP(i, n)
    {
        ignored = scanf("%llu", &t[i]);
    }

    REP(i, m)
    {
        int d = 0;
        LL time = 0;
        LL delay = 0;
      
        ignored = scanf("%d", &d);

        REP(j, n)
        {
            time = std::max(time + d, t[j]);
            delay += std::max(time - t[j], 0ll);
        }

        ignored = printf("%lld\n", delay);
    }

    (void) ignored;

    return 0;
}