This commit is contained in:
Zengtudor 2024-08-13 16:09:40 +08:00
parent 0464e800da
commit 4d1f526920

View File

@ -1,112 +1,55 @@
/* //暴力 80point 逆天了,样例太水了
[set容器]
- `1 x`: $x$
- `2 x`: $x$ $1$
- `3 l r`: $l\le x\le r$ $x$ []
- `4 x`: <= x `-1`
- `5 x`: >= x `-1`
1 2
*/
#include<bits/stdc++.h> #include<bits/stdc++.h>
using namespace std; using namespace std;
#define int long long
const int MAX_X=1e5+5; const int MAX_N = 5e8+5;
int q; int a[MAX_N];
vector<int>v(MAX_X);
set<int> s;
int getint();
signed main(signed argc,char *argv[]){ int readint();
#ifdef OITEST
cout<<"TESTING"<<endl; int main(){
#define AS(c){if(!(c)){cerr<<"assert failed:"<<#c<<endl;return -1;}} // auto a = new int[MAX_N];
#define ASM(a,b){if((a)!=(b)){cerr<<"assert failed: "<<a<<endl<<b<<endl;return 1;}} const int n = readint();
AS(argc==3) for(int i=1;i<=n;i++){
auto fin = freopen(argv[1],"r",stdin); const int m = readint();
AS(fin!=NULL) if(m==1){
ifstream afile(argv[2]); const int x=readint();
stringstream ss; a[x]++;
#define cout ss }else if(m==2){
int ans_num = 0; const int x=readint();
#endif a[x]--;
q=getint(); }else if(m==3){
for(int i=1;i<=q;i++){ const int l=readint(),r=readint();
const int n=getint();
#ifdef OITEST
if(n>=3){
ans_num++;
}
#endif
if(n==1){
const int x=getint();
/*auto state = */s.insert(x);
if(x>=v.size())v.resize(x+1);
v[x]++;
}else if (n==2) {
const int x=getint();
v[x]--;
if(v[x]==0){s.erase(x);}
}else if(n==3){
const int l=getint(),r=getint();
const auto sl=s.lower_bound(l)
,sr=s.lower_bound(r);
int ans=0; int ans=0;
for(auto i=sl;i!=sr;i++){ for(int j=l;j<=r;j++){
ans+=(*i)*v[(*i)]; ans+=j*a[j];
}
if ((*sr)==r) {
ans+=(*sr)*v[(*sr)];
} }
cout<<ans<<endl; cout<<ans<<endl;
}else if(n==4){ }else if(m==4){
const int x=getint(); const int x = readint();
// if(x==99){ for(int j=x;j>=0;j--){
// cerr<<"debugging"<<endl; if(a[j]){
// } cout<<j<<endl;
auto it=s.lower_bound(x); goto out1;
if((*it)==x){ }
cout<<x<<endl; }
continue;
}else{
it--;
if((*it)<x){
cout<<(*it)<<endl;
continue;
}else{
cout<<-1<<endl; cout<<-1<<endl;
continue; 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<<(*it)<<endl;
}else if(n==5){
const int x=getint();
auto it=s.lower_bound(x);
if(it==s.end()){
cout<<-1<<endl; cout<<-1<<endl;
continue; out:;
}
cout<<(*it)<<endl;
} }
} }
#ifdef OITEST
for(int i=1;i<=ans_num;i++){
int cans ,myans;
afile>>cans;
ss>>myans;
ASM(cans,myans)
}
#endif
} }
int getint(){ int readint(){
int x=0,w=1; int x=0,w=1;
char ch=0; char ch=0;
while(!isdigit(ch)){ while(!isdigit(ch)){