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