bdfz_2024_summer/day10/U88589/U88589.cpp
2024-08-13 17:19:19 +08:00

63 lines
1.3 KiB
C++

//暴力 80point 逆天了,样例太水了
#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 5e8+5;
int a[MAX_N];
int readint();
int main(){
const int n = readint();
for(int i=1;i<=n;i++){
const int m = readint();
if(m==1){
const int x=readint();
a[x]++;
}else if(m==2){
const int x=readint();
a[x]--;
}else if(m==3){
const int l=readint(),r=readint();
int ans=0;
for(int j=l;j<=r;j++){
ans+=j*a[j];
}
cout<<ans<<endl;
}else if(m==4){
const int x = readint();
for(int j=x;j>=0;j--){
if(a[j]){
cout<<j<<endl;
goto out1;
}
}
cout<<-1<<endl;
out1:;
}else if(m==5){
const int x = readint();
for(int j=x;j<MAX_N;j++){
if(a[j]){
cout<<j<<endl;
goto out;
}
}
cout<<-1<<endl;
out:;
}
}
}
int readint(){
int x=0,w=1;
char ch=0;
while(!isdigit(ch)){
if(ch=='-')w=-1;
ch=getchar();
}
while(isdigit(ch)){
x=x*10+(ch-'0');
ch=getchar();
}
return x*w;
}