multiset 全错,可恶
查看原帖
multiset 全错,可恶
442725
余歆楼主2021/12/25 20:33

上代码

#include<bits/stdc++.h>
using namespace std;
multiset<int> q;
int n,t,x,order;
multiset<int>::iterator it, j;
int main()
{
    q.insert(-0x7fffffff);
    q.insert(0x7fffffff);
    cin>> n;
    while(n--){
        cin>>t>>x;
        if(t==1){
            it = q.lower_bound(x);    
            order = 0;
            for(j = q.begin(); j != it; j++,order++);
           		cout<< order<< endl ;
        }
        else if(t==2){
            order = 0;
            for(it = q.begin(); it != q.end(); it++){
                order++;
                if(order==x)
                    cout<<*it;
                }
        }
        else if(t==3){
            it = q.lower_bound(x);
            cout<< *--it <<endl;
        	}
        else if(t==4)
            cout<<*q.upper_bound(x)<<endl;
        else
            q.insert(x);
    }
    return 0;
}

望大神指教

2021/12/25 20:33
加载中...