fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_SIZE = 1300000;
  5.  
  6. int main() {
  7. int n, m, documentsList[MAX_SIZE + 1];
  8. cin >> n >> m;
  9. for (int i = 1; i <= n; ++i) {
  10. cin >> documentsList[i];
  11. }
  12. int start = 1;
  13. for (int i = 1; i <= m; ++i) {
  14. int operation;
  15. cin >> operation;
  16. if (operation == 2) {
  17. cin >> documentsList[++n];
  18. } else if (operation == 1 && start <= n) {
  19. ++start;
  20. }
  21. }
  22. cout << n - start + 1 << "\n";
  23. for (int i = start; i <= n; ++i) {
  24. cout << documentsList[i] << " ";
  25. }
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5284KB
stdin
4 3
30 21 81 26
2 68
2 64
1
stdout
5
21 81 26 68 64