TLE 求调
查看原帖
TLE 求调
252549
Iwara楼主2023/10/7 19:51
#include<bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long ll;
ll t;
ll x;
int main(){
	ios::sync_with_stdio(0);
	cin>>t;
	while(t--){
		vector<ll> vec;
		ll sz=0;
		while(1){
			cin>>x;
			if(!x)break;
			if(x!=-1){
				sz++;
				ll p=lower_bound(vec.begin(),vec.end(),x)-vec.begin();
				vec.insert(vec.begin()+p,x);
			}
			else{
				cout<<vec[(sz+1)/2-1]<<'\n';
				vec.erase(vec.begin()+(sz+1)/2-1);
				sz--;
			}
		}
	}
	return 0;
}

感觉复杂度正确(

2023/10/7 19:51
加载中...