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. if(n<=0){
  25. cout <<" ";
  26. }else{
  27. cout << n << "\n ";
  28. for (int i = 1; i <= n; ++i) {
  29. cout << v[i] << " ";
  30. }}
  31. return 0;
  32. }
Success #stdin #stdout 0.01s 5596KB
stdin
4 11
30 21 81 26
2 68
2 64
1
2 64
1
1
1
1
1
2 0
1
stdout
1
 0