#include <iostream>
#include <set>
using namespace std;
typedef pair<int,int> pii;
int N,M;
int H[100005];
int t,x,y;
multiset<int> A,B;
multiset<pii> P;
void add(int i){
if(i==-1 or i==N-1)
return;
int a=H[i];
int b=H[i+1];
if(a>b)
swap(a,b);
A.insert(a);
B.insert(b);
}
void remove(int i){
if(i==-1 or i==N-1)
return;
int a=H[i];
int b=H[i+1];
if(a>b)
swap(a,b);
A.erase(a);
B.erase(b);
}
int query(int h){
int res=0;
for(int x:A)
if(x<h)
res++;
for(int x:B)
if(x<h)
res--;
return res;
}
/*
void print(){
cout<<"******\n";
cout<<"startUp ";
for(int x:startUp)
cout<<x<<" ";
cout<<"\n";
cout<<"startDown ";
for(int x:startDown)
cout<<x<<" ";
cout<<"\n";
cout<<"endUp ";
for(int x:endUp)
cout<<x<<" ";
cout<<"\n";
cout<<"endDown ";
for(int x:endDown)
cout<<x<<" ";
cout<<"\n";
cout<<"******\n";
}
*/
int main(){
cin>>N>>M;
for(int i=0;i<N;i++)
cin>>H[i];
for(int i=0;i<N-1;i++)
add(i);
while(M--){
cin>>t;
if(t==1){
cin>>x>>y;
x--;
remove(x-1);
remove(x);
H[x]=y;
add(x-1);
add(x);
}
else{
cin>>x;
cout<<query(x)<<"\n";
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |