建议加强数据
查看原帖
建议加强数据
275282
zhangce楼主2023/12/23 13:47

这题数据太水了,暴力代码竟然能过

#include <bits/stdc++.h>
using namespace std;
inline long long read() {
	long long x = 0, f = 1; char c = getchar();
	while (c > '9' || c < '0') {
		if (c == '-') f = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + c - 48, c = getchar();
	return x * f;
}
int a[100001], n, opt, nx, cnt;
int main(void) {
	n = read();
	a[0] = -100000000;
	for (int i = 1; i <= n; i++) {
		opt = read(), nx = read();
		if (opt == 1) {
			a[++cnt] = nx;
			for (int j = cnt; a[j] < a[j - 1]; j--) swap(a[j], a[j - 1]);
		} else if (opt == 2) {
			int j = 1;
			while (a[j] != nx) j++;
			for (int k = j; k < cnt; k++) a[k] = a[k + 1];
			cnt--;
		} else if (opt == 3) {
			int j = 1;
			while (a[j] < nx) j++;
			printf("%d\n", j);
		} else if (opt == 4) {
			printf("%d\n", a[nx]);
		} else if (opt == 5) {
			int j = 1;
			while (a[j] < nx && j <= cnt) j++;
			printf("%d\n", a[j - 1]);
		} else {
			int j = cnt;
			while (a[j] > nx && j > 0) j--;
			printf("%d\n", a[j + 1]);
		}
	}
	return 0;
}
2023/12/23 13:47
加载中...