//https://l...content-available-to-author-only...e.ro/submission/1595800
#include <iostream>
using namespace std;
const int MAX_SIZE = 9;
int main() {
int n, m, v[MAX_SIZE + 1], x;
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
cin >> v[i];
}
for (int j = 1; j <= m; ++j) {
int k;
cin >> k;
if (k == 1) {
if (n > 0) {
--n;
for (int i = 1; i <= n; ++i) {
v[i] = v[i + 1];
}
}
} else if (k == 2) {
if (n < MAX_SIZE) {
cin >> x;
++n;
v[n] = x;
}
}
}
cout << n << "\n";
for (int i = 1; i <= n; ++i) {
cout << v[i] << " ";
}
return 0;
}
Ly9odHRwczovL2wuLi5jb250ZW50LWF2YWlsYWJsZS10by1hdXRob3Itb25seS4uLmUucm8vc3VibWlzc2lvbi8xNTk1ODAwCiNpbmNsdWRlIDxpb3N0cmVhbT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNvbnN0IGludCBNQVhfU0laRSA9IDk7CgppbnQgbWFpbigpIHsKICAgIGludCBuLCBtLCB2W01BWF9TSVpFICsgMV0sIHg7CiAgICBjaW4gPj4gbiA+PiBtOwogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgKytpKSB7CiAgICAgICAgY2luID4+IHZbaV07CiAgICB9CiAgICBmb3IgKGludCBqID0gMTsgaiA8PSBtOyArK2opIHsKICAgICAgICBpbnQgazsKICAgICAgICBjaW4gPj4gazsKICAgICAgICBpZiAoayA9PSAxKSB7CiAgICAgICAgICAgIGlmIChuID4gMCkgewogICAgICAgICAgICAgICAgLS1uOwogICAgICAgICAgICAgICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgKytpKSB7CiAgICAgICAgICAgICAgICAgICAgdltpXSA9IHZbaSArIDFdOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIGlmIChrID09IDIpIHsgCiAgICAgICAgICAgIGlmIChuIDwgTUFYX1NJWkUpIHsgCiAgICAgICAgICAgICAgICBjaW4gPj4geDsKICA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SAKCjkgOQozMCAyMSAtODEgMjYgOTUgODYgLTM2NSAwIDkwMCAKMiAzMCAKMiAyMSAKMQoxCjIgLTk5IAoxCjIgODggCjIgNzcgCjIgNTUgLSZndDsxMgoyNiA5NSA4NiAtMzY1IDAgOTAwIDMwIDIxIC05OSA4OCA3NyA1NQoKCjkgOQozMCAyMSAtODEgMjYgOTUgODYgLTM2NSAwIDkwMCAKMiAzMCAKMiAyMSAKMiAtODEgCjIgMjYgCjIgOTUgCjIgODYgCjIgLTM2NSAKMiAwIAoyIDkwMCAtJmd0OzE4CjMwIDIxIC04MSAyNiA5NSA4NiAtMzY1IDAgOTAwIDMwIDIxIC04MSAyNiA5NSA4NiAtMzY1IDAgOTAwIAoKNCA1CjMwIDIxIC04MSAyNgoyIDk1CjIgODYKMiAtMzY1CjIgMAoyIDkwMCAtICZndDs5CjMwIDIxIC04MSAyNiA5NSA4NiAtMzY1IDAgOTAwIAoKNCA0CjMwIDIxIC04MSAyNgoxCjEKMQoxLSZndDswCgo0IDQKMzAgMjEgODEgMjYKMQoxCjEKMS0mZ3Q7MAoKNCAzCjMwIDIxIDgxIDI2CjEKMQoxLSZndDsxCjI2Cgo0IDMKMzAgMjEgODEgMjYKMiA2OAoyIDY0CjEtJmd0OzUKMjEgODEgMjYgNjggNjQg
4 7
30 21 -81 26
2 6
2 95
2 86
2 -365
2 0
1
1 - >8
21 -81 26 6 95 86 -365 0
4 8
30 21 -81 26
2 6
2 95
2 86
2 -365
2 0
2 900
1
1 - >8
21 -81 26 6 95 86 -365 0 am setat constanta = 9, ca sa pot testa nr maxim de elemente, La acest test imi dau seama ca se acceseaza gresit valoarea maxima a lui n, cred
4 7
30 21 -81 26
2 6
2 95
2 86
2 -365
2 0
2 900
1 - >9
30 21 -81 26 6 95 86 -365 0 am setat constanta = 9, ca sa pot testa nr maxim de elemente
4 6
30 21 -81 26
2 6
2 95
2 86
2 -365
2 0
2 900 - >9
30 21 -81 26 6 95 86 -365 0 am setat constanta = 9, ca sa pot testa nr maxim de elemente
1 2
5
1
2 9-> 1
9
9 9
30 21 -81 26 95 86 -365 0 900
2 30
2 21
1
1
2 -99
1
2 88
2 77
2 55 ->12
26 95 86 -365 0 900 30 21 -99 88 77 55
9 9
30 21 -81 26 95 86 -365 0 900
2 30
2 21
2 -81
2 26
2 95
2 86
2 -365
2 0
2 900 ->18
30 21 -81 26 95 86 -365 0 900 30 21 -81 26 95 86 -365 0 900
4 5
30 21 -81 26
2 95
2 86
2 -365
2 0
2 900 - >9
30 21 -81 26 95 86 -365 0 900
4 4
30 21 -81 26
1
1
1
1->0
4 4
30 21 81 26
1
1
1
1->0
4 3
30 21 81 26
1
1
1->1
26
4 3
30 21 81 26
2 68
2 64
1->5
21 81 26 68 64