@[sxy2012yutiti](/user/729386)
这题没那么复杂……直接数组模拟就过了。
跑得飞快。
```cpp
#include <bits/stdc++.h>
using namespace std;
int q, op, x;
int n, a[10005];
int main(void) {
cin >> q;
while (q--) {
cin >> op >> x;
if (op == 1) {
int ans = 1;
for (int i = 1; i <= n; i++)
if (a[i] < x)
ans++;
else break;
cout << ans << endl;
}
else if (op == 2)
cout << a[x] << endl;
else if (op == 3) {
int ans = -2147483647;
for (int i = 1; i <= n; i++)
if (a[i] < x)
ans = max(ans, a[i]);
else break;
cout << ans << endl;
}
else if (op == 4) {
int ans = 2147483647;
for (int i = n; i >= 1; i--)
if (a[i] > x)
ans = min(ans, a[i]);
else break;
cout << ans << endl;
}
else {
int idx = n + 1;
for (int i = 1; i <= n; i++)
if (a[i] > x) {
idx = i;
break;
}
for (int i = n; i >= idx; i--)
a[i + 1] = a[i];
a[idx] = x;
n++;
}
}
return 0;
}
```
by jesse1216 @ 2024-03-23 22:38:25
@[jesse1216](/user/530437) 啊啊啊,过样例了吗
by sxy2012yutiti @ 2024-03-24 08:30:22
@[jesse1216](/user/530437) 没事,我是从板子搞过来的,几乎没写
by sxy2012yutiti @ 2024-03-24 08:30:54