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
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <bits/stdc++.h>
#include <unistd.h>
#define inf 1000000007LL
#define INF 1000000000000000007LL
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define st first
#define nd second
#define ll long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define vll vector<long long>
#define vpii vector< pair<int,int> >
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define LOG(x) (63-__builtin_clzll(x))
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i, n) for(int i=1; i<=(n); ++i)
#define endr cerr<<'\n'
#define endl '\n'
#ifdef DEBUG
#define pv(...) cerr<<'\n',dbg(#__VA_ARGS__, __VA_ARGS__)
#define ps(x) {cerr<<'\n'<<#x<<":\n:";for(auto q:(x)){cerr<<q<<" ";}cerr<<'\n';}
#define pa(x, xs) {cerr<<'\n'<<#x<<":\n:";for(int q=0; q<=(xs); ++q){cerr<<x[q]<<" ";}cerr<<'\n';}
#define pal(x, xs) {cerr<<'\n'<<#x<<":\n";for(int q=0; q<=(xs); ++q){cerr<<q<<": "<<setw(q? 3-(int32_t)log10(q):3)<<x[q]<<'\n';}cerr<<'\n';}
#define ppii(x, xs) {cerr<<'\n'<<#x<<":\n";for(int q=0; q<=(xs); ++q){cerr<<q<<": "<<setw(q? 6-(int32_t)log10(q):6)<<x[q].first<<" "<<setw(5)<<x[q].second<<'\n';}cerr<<'\n';}
#define pm(x, xn, xm) {cerr<<'\n'<<#x<<":\n";for(int qa=0; qa<=(xn); ++qa){for(int qb=0; qb<=(xm); ++qb){cerr<<setw(6)<<x[qa][qb]<<" ";}cerr<<'\n';}cerr<<'\n';}
#else
#define cerr if(0)cout
#define pv(...) if(0)endr
#define ps(x) if(0)endr
#define pa(x, xs) if(0)endr
#define pal(x, xs) if(0)endr
#define ppii(x, xs) if(0)endr
#define pm(x, xn, xm) if(0)endr
#endif
using namespace std;
template<class T> void dbg(const char* xn, T x){cerr<<xn<<": "<<x<<"\n";} template<class T, class... TA> void dbg(const char* xn, T x, TA... t){while(*xn!=',')cerr<<*xn++;cerr<<": "<<x<<",";dbg(xn+1, t...);}
template<class T> inline bool upd_max(T &x, T y){return y>x?x=y,true:false;} template<class T> inline bool upd_min(T &x, T y){return y<x?x=y,true:false;}
const int N = 1000007;
inline void read(ll &x)
{
  register char c;
  x = 0;

  do c = getchar_unlocked();
  while (c<'0' || c>'9');

  do x = (x<<1) + (x<<3) + c-'0', c = getchar_unlocked();
  while (c>='0' && c<='9');
}

inline void write(ll x)
{
  if (x == 0)
  {
    putchar_unlocked('0');
    return;
  }

  register char c[19];
  register int i = 0;

  while (x)
  {
    c[++i] = x%10 + 48;
    x = x/10;
  }

  while (i) putchar_unlocked(c[i--]);
}

ll n, m, T[N], D[N];


void solve()
{
  read(n); read(m);
  rep1(i, n) read(T[i]);
  rep1(i, m) read(D[i]);

  sort(T+1, T+n+1);

  for (int oven=1; oven<=m; ++oven)
  {
    ll last = 0, res = 0;
    for (int i=1; i<=n; ++i)
    {
      if (last > T[i] - D[oven])
      {
        last += D[oven];
        res += last - T[i];
      }
      else
      {
        last = T[i];
      }
    }

    write(res); puts("");
  }
}

int32_t main()
{

  solve();

return 0;
}