暴力AC(赏个赞)
2026-04-26 15:00:56
发布于:浙江
7阅读
0回复
0点赞
直接暴力好吧。
小学生易懂。
#include<bits/stdc++.h>
using namespace std;
int n;
int const N=8005;
int a[N];
int uid[N];
int q;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>q;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
while(q--)
{
short s;
int x,v;
cin>>s;
if(s==1)
{
cin>>x>>v;
a[x]=v;
}
else if(s==2)
{
cin>>x;
int sum=n;
for(int i=1;i<x;i++)
{
if(a[i]>a[x])
{
sum--;
}
}
for(int i=x+1;i<=n;i++)
{
if(a[i]>=a[x])
{
sum--;
}
}
cout<<sum<<"\n";
}
}
return 0;
}
这里空空如也




有帮助,赞一个