样例与hank能过0分求助(玄关)Orz
查看原帖
样例与hank能过0分求助(玄关)Orz
1199534
ycy1124楼主2024/5/9 13:23
#include<bits/stdc++.h>
using namespace std;
set<int>a;
set<int>::iterator t,t1;
int main()
{
	int q;
	scanf("%d",&q);
	for(int i=1;i<=q;i++){
		int ch;
		scanf("%d",&ch);
		int x;
		scanf("%d",&x);
		if(ch==5){
			a.insert(x);
		}
		else if(ch==1){
			if(a.empty()){
				printf("1\n");
			}
			else if(x>*a.end()){
				printf("%d\n",a.size()+1);
			}
			else{
				t=a.lower_bound(x);
				int bj=0;
				for(t1=a.begin();*t1<=*t;t1++){
					bj++;
				}
				printf("%d\n",bj);
			}
		}
		else if(ch==2){
			t=a.begin();
			for(int i=1;i<x;i++,t++){
			}
			printf("%d\n",*t);
		}
		else if(ch==3){
			if(a.empty()){
				printf("-2147483647\n");
			}
			else if(x<=*a.begin()){
				printf("-2147483647\n");
			}
			else{
				t=a.lower_bound(x);
				printf("%d\n",*(--t));
			}
		}
		else if(ch==4){
			if(a.empty()){
				printf("2147483647\n");
			}
			else{
				t1=a.end();
				t1++;
				if(x>=*t1){
					printf("2147483647\n");
				}
				else{
					t=a.upper_bound(x);
					printf("%d\n",*t);
				}
			}
		}
	}
	return 0;
}
2024/5/9 13:23
加载中...