fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_SIZE = 10000;
  5.  
  6. int main() {
  7. int n, m, v[MAX_SIZE + 1], k, x, t;
  8. cin >> n;
  9. for (int i = 1; i <= n; ++i) {
  10. cin >> v[i];
  11. }
  12. cin >> m;
  13. while(m--) {
  14. cin >> k;
  15. if(k == 1) {
  16. cin >> x;
  17. ++n;
  18. v[n] = x;
  19. } else {
  20. --n;
  21. }
  22. }
  23. t = n;
  24. cout << t << "\n ";
  25. for (int i = 1; i <= t; ++i) {
  26. cout << v[i] <<" ";
  27. }
  28. return 0;
  29. }
Success #stdin #stdout 0s 5268KB
stdin
7
5 -4 0 -7 7 7 2
8
2
2
1 2000000000
2
1 300
2
1 300
1 2000000000
stdout
7
 5 -4 0 -7 7 300 2000000000