提交时间:2021-12-06 14:01:28

运行 ID: 33486

#include<bits/stdc++.h> using namespace std; int Read() { int x=0; char c=getchar(); for(; c<'0' || c>'9'; c=getchar()); for(; c<='9' && c>='0'; c=getchar()) x=(x<<3)+(x<<1)+(c^48); return x; } int main(){ freopen("sort.in","r",stdin); freopen("sort.out","w",stdout); int n,q,a[8010],x,y,v,ans=0; n=Read(),q=Read(); for(int i=1;i<=n;++i) a[i]=Read(); for(int i=1;i<=q;++i) { x=Read(); if(x==1) { y=Read(),v=Read(); a[y]=v; } if(x==2) { y=Read(); for(int j=1;j<y;++j) { if(a[j]<=a[y]) ++ans; } for(int j=y+1;j<=n;++j) { if(a[j]<a[y]) ++ans; } cout<<ans+1<<'\n'; ans=0; } } return 0; }//sort