fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_SIZE = 10000;
  5.  
  6. int main() {
  7. int n, v[MAX_SIZE + 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. cin >> k;
  15. if (k == 1) {
  16. if(n < MAX_SIZE){
  17. cin >> x;
  18. ++n;
  19. v[n] = x;
  20. }
  21. }
  22. if (k == 2) {
  23. --n;
  24. }
  25. }
  26. cout << n << "\n ";
  27. for (int i = 1; i <= n; ++i) {
  28. cout << v[i] << " ";
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0s 5284KB
stdin
3
1 2 3
2
2
2

1
10000
9
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9-10
 10000 1 2 3 4 5 6 7 8 9 

9
0 1 2 3 4 5 6 7 8
1
1 2222 - 10
 0 1 2 3 4 5 6 7 8 2222 


10
0 1 2 3 4 5 6 7 8 55
10
2 2 2 2 2 2 2 2 2 2 - 0

9
0 1 2 3 4 5 6 7 8 
1
1 55 - 10
0 1 2 3 4 5 6 7 8 55

10
1 2 3 4 5 6 7 8 9 0 
2
2
2 - 8
1 2 3 4 5 6 7 8 

10
1 2 3 4 5 1 2 3 4 5 
10
2
2
2
2
2
2
2
2
2
2 -0




5
1 2 3 4 5
5
2
2
2
2
2 - 0



1
1
7
2
1 2
1 2
1 9
2
2
2 - 0


1 2 3 
4
2
2
2
1 9
-1
9


3
1 2 3
3
1 9
1 6
1 0
-6
1 2 3 9 6 0

3
1 2 3
4 
2
2
1 9
2
-1
1

3
1 2 3 
3
2
2
1 9
-2
1 9

3
1 2 3
4
2
2
2
1 0
-1
0


3
1 2 3
5
2
2
2
1 9
2
-0

3
1 2 3 
3
2
2
2
-0

7
5 -4 0 -7 7 7 2
5
2
1 100
2
1 0
1 3
-8
5 -4 0 -7 7 7 0 3

3
1 2 3 
6
1 9
1 9
1 9
1 9
1 9
1 9
-9
1 2 3 9 9 9 9 9 9

https://l...content-available-to-author-only...e.ro/submission/1592550
stdout
1
 1