全WA,求调
查看原帖
全WA,求调
1198506
wo488楼主2024/10/17 20:22
#include<bits/stdc++.h>
#include<iostream>

using namespace std;

int main() {
	int n;
	
	int cop, x,y;
	cin >> n;
	int a[10001];
	int cnt = 1;
	int tmp=0;
	for (int i = 1; i <= n; i++) {
		cin >> cop;
		cin >> x;
		switch (cop) {
		case 1: {
			int temp = lower_bound(a+1, a+cnt, x)-a;
			
			cout << tmp<< endl;
			break;
		}                   //查询数 $x$ 的排名;
		case 2: { y = a[x]; cout << y << endl; break; }//查询排名为 $x(x\ge 1)$ 的数
		case 3: {
			auto lower = lower_bound(a+1, a+cnt, x);
			if (lower-a ==1 )
				cout << -2147483647 << endl;
			else
				cout << *(lower - 1) << endl;
			break;


		}       //求 $x$ 的前驱(前驱定义为小于 $x$,且最大的数)
		case 4: {
			auto lower = lower_bound(a+1, a+cnt, x);
			if (lower - a == cnt)
				cout << 2147483647 << endl;
			else if (x == *lower)
				cout << *(lower + 1) << endl;
			else
				cout << *(lower) << endl;
			break;
		}
			// 求 $x$ 的后继(后继定义为大于 $x$,且最小的数)。
		case 5: {
			a[cnt] = x;
			cnt++;
			sort(a+1, a+cnt);//插入一个数 $x$
		}
		}

	}

}
2024/10/17 20:22
加载中...