答案就等于两个点之间priority最小那个……线段树维护一下即可。由定义就能得出来嘛
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define MAXN 300010
#define MAXM 6000010
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define eps 1e-8
struct data{
ll v;
ll k;
data(){
}
data(ll _v,ll _k){
v=_v;
k=_k;
}
friend bool operator <(data x,data y){
return x.k<y.k;
}
};
data v[MAXM];
ll son[MAXM][2];
ll a[MAXN];
ll tot;
ll n,m;
ll rt;
inline void ud(ll x){
v[x]=min(v[son[x][0]],v[son[x][1]]);
}
void change(ll &x,ll y,ll z,ll p,ll key){
if(!x){
x=++tot;
}
if(y==z){
v[x]=data(p,key);
return ;
}
ll mid=y+z>>1;
if(p<=mid){
change(son[x][0],y,mid,p,key);
}else{
change(son[x][1],mid+1,z,p,key);
}
ud(x);
}
void del(ll x,ll y,ll z,ll p){
if(y==z){
v[x]=v[0];
return ;
}
ll mid=y+z>>1;
if(p<=mid){
del(son[x][0],y,mid,p);
}else{
del(son[x][1],mid+1,z,p);
}
ud(x);
}
data ask(ll x,ll y,ll z,ll l,ll r){
if(y==l&&z==r){
return v[x];
}
ll mid=y+z>>1;
if(r<=mid){
return ask(son[x][0],y,mid,l,r);
}else if(l>mid){
return ask(son[x][1],mid+1,z,l,r);
}else{
return min(ask(son[x][0],y,mid,l,mid),ask(son[x][1],mid+1,z,mid+1,r));
}
}
int main(){
v[0].k=1000000000000ll;
ll i,x,y;
char o[5];
scanf("%lld%lld",&n,&m);
for(i=1;i<=n;i++){
scanf("%lld",&a[i]);
}
for(i=1;i<=n;i++){
scanf("%lld",&x);
change(rt,-INF,INF,a[i],x);
}
while(m--){
scanf("%s",o);
if(o[0]=='I'){
scanf("%lld%lld",&x,&y);
change(rt,-INF,INF,x,y);
}
if(o[0]=='D'){
scanf("%lld",&x);
del(rt,-INF,INF,x);
}
if(o[0]=='Q'){
scanf("%lld%lld",&x,&y);
if(x>y){
swap(x,y);
}
printf("%lld\n",ask(rt,-INF,INF,x,y).v);
}
}
return 0;
}
/*
*/