- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- #include <cstring>
- #include <string>
- #include <vector>
- #include <stack>
- #include <map>
- #include <set>
- #include <queue>
- #include <list>
- #include <cstdlib>
- #include <iterator>
- #include <cmath>
- #include <iomanip>
- #include <bitset>
- #include <cctype>
- using namespace std;
- #define cin_1(a) scanf("%d",&a)
- #define cin_2(a,b) scanf("%d%d",&a,&b)
- #define cin_3(a,b,c) scanf("%d%d%d",&a,&b,&c)
- #define max_3(a,b,c) max(max(a,b),c)
- #define ll long long
- #define rint register int
- #define mem0(x) memset(x, 0, sizeof(x))
- #define mem1(x) memset(x, -1, sizeof(x))
- /**
- vector<int>::iterator it;
- for(it=vec.begin();it!=vec.end();it++)
- cout<<*it<<endl;
- */
- ///2147483647 -2147483648
- ///9223372036854775807 -9223372036854775808
- const int inf = 0x3f3f3f3f;
- const ll inff = 0x3f3f3f3f3f3f3f3f;
- //map<ll,ll>mp;
- //set<ll>st;
- vector<int>a;
- /***********************************************/
- ///http://oj.acm.zstu.edu.cn/JudgeOnline/problem.php?id=4405
- /// 招生
- int main() {
- int n;
- cin>>n;
- int cnt=0;
- while(n--)
- {
- int opt,x;
- cin>>opt>>x;
- if(opt==1)
- {
- cnt++;/// 插入第一个比 x 大的位置前面 (升序)
- a.insert(lower_bound(a.begin(),a.end(),x),x);//<-<-
- }
- else if(opt==2)
- {
- cnt--;
- a.erase(lower_bound(a.begin(),a.end(),x));//<-<-
- }
- else if(opt==3)
- {
- if(cnt-x>=0)
- {
- int p=cnt-x;
- /// 输出第 p 个成绩
- cout<<a[p]<<endl;
- }
- }
- else
- {
- /// 总数减去小于 x 的人数, 即为被录取的人数
- cout<<cnt-(lower_bound(a.begin(),a.end(),x)-a.begin())<<endl;//<-<-
- }
- }
- return 0;
- }
来源: http://www.bubuko.com/infodetail-2928114.html