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