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
#include <iostream>
using namespace std;
long long custTab[300000];
int main()
{
    ios_base::sync_with_stdio(false);
    int piekC = 0, custC = 0, curPiek = 0; 
    long long wyn = 0, hour = 0;
    cin>>custC>>piekC;
    for(int i=0; i<custC; ++i){
        cin>>custTab[i];
    }
    for(int i = 0; i<piekC; ++i){
        cin>>curPiek;
        for(int j=0; j<custC; ++j){
            if(curPiek + hour <= custTab[j]){
                hour = custTab[j];
            }else{
                wyn+= (curPiek + hour - custTab[j]);
                hour = curPiek + hour;
            }
        }
        hour = 0;
        cout<<wyn<<endl;
        wyn = 0;
    }
    return 0;
}