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