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
#include <iostream>
#include<stdint.h>
#include<algorithm>

using namespace std;

int main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
int k,p;
uint64_t ki[200001];
uint64_t pj[200001];
uint64_t odp,t;//t-chwila obecna

cin >>k>>p;
 for(int i=0; i<k; i++){
  cin >> ki[i];
 }
 for(int j=0; j<p; j++){
  
  cin >> pj[j];
  odp=0;
  t=0;
  for(int i=0; i<k; i++){
     if(t+pj[j]>ki[i]){odp=odp+t-ki[i]+pj[j];t=t+pj[j];}
     else{
        t=ki[i];
     }
  }
    cout << odp << '\n';
 }
  




return 0;
}