样例过了全WA了,set大佬come to help me。
查看原帖
样例过了全WA了,set大佬come to help me。
653212
shensiyuan2011楼主2022/4/13 16:57
#include <bits/stdc++.h>
using namespace std;
set <int>a;
int main(){
	ios::sync_with_stdio(false);
	int n,p,len;
	cin>>n;
	while (n--){
		cin>>p>>len;
		if (p==1){
			if (a.find(len)!=a.end())cout<<"Already Exist";
			else a.insert(len);
		}else if (a.empty())cout<<"Empty";
		else{
			set<int>::iterator i=a.lower_bound(len),j=i;
			if (j!=	a.begin())--j;
			if (i!=a.end()&&len-(*j)>(*i)-len)j=i;
			cout<<(*j)<<endl;
			a.erase(j);
		}
	}
	return 0;
}

怎么回事啊,样例过了全WA!

2022/4/13 16:57
加载中...