fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int X,N,Q;
  6. cin >> X >> N;
  7. vector<int> W(N);
  8.  
  9. for(int i=0; i<N; i++){
  10. cin >> W.at(i);
  11. }
  12.  
  13. cin >> Q;
  14. vector<int> P(Q);
  15.  
  16. for(int i=0; i<Q; i++){
  17. cin >> P.at(i);
  18. if(P.at(i)==0){
  19. X += P.at(i);
  20. cout << X << endl;
  21. }else{
  22. X -= P.at(i);
  23. cout << X << endl;
  24. }
  25. }
  26.  
  27. // your code goes here
  28. return 0;
  29. }
Success #stdin #stdout 0.01s 5280KB
stdin
31
4
15 92 65 35
4
3
1
4
1
stdout
28
27
23
22