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
#include <iostream>
#include <cstdio>
using namespace std;

long long t[ 200001 ];

int main()
{
    int n, m, d;
    long long result, last;
    scanf( "%d%d", &n, &m );

    for ( int i = 0; i < n; ++i )
    {
        scanf( "%lld", &t[ i ] );
    }

    while ( m-- )
    {
        scanf( "%d", &d );
        result = last = 0;
        for ( int i = 0; i < n; ++i )
        {
            last += d;
            if ( last < t[ i ] ) last = t[ i ];
            else result += last - t[ i ];
        }
        printf( "%lld\n", result );
    }

}