fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, v[900000], m, w[400000], x;
  6. cin >> n >> m;
  7. for (int i = 1; i <= n; ++i) {
  8. cin >> v[i];
  9. }
  10. for (int j = 1; j <= m; ++j) {
  11. cin >> w[j];
  12. if (w[j] == 1) {
  13. for (int i = 1; i < n; ++i) {
  14. v[i] = v[i + 1];
  15. }
  16. --n;
  17. }
  18. if (w[j] == 2) {
  19. ++n;
  20. cin >> x;
  21. v[n] = x;
  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 5288KB
stdin
Standard input is empty
stdout
0