#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000005;
int N,M, h[MAXN];
int marc[MAXN];
int main()
{
cin>>N>>M;
for(int i = 1; i <= N; i++)cin>>h[i];
for(int i = 1; i <= N; i++)
{
if(i==N)
{
marc[h[i]]++;
break;
}
int s = min(h[i],h[i+1]), f = max(h[i],h[i+1]);
if(s==f)
{
marc[s]++;
continue;
}
for(int k = s; k < f; k++)marc[k]++;
}
for(int m = 1; m <= M; m++)
{
int q; cin>>q;
if(q==1)
{
int p,v; cin>>p>>v;
if(p==N)
{
marc[h[p]]--;
h[p]=v;
continue;
}
int ls = min(h[p],h[p+1]), lf = max(h[p],h[p+1]);
for(int k = ls; k < lf; k++)marc[k]--;
h[p]=v;
int s = min(h[p],h[p+1]), f = max(h[p],h[p+1]);
for(int k = s; k < f; k++)marc[k]++;
}
else
{
int x; cin>>x;
cout<<marc[x]<<"\n";
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
335 ms |
4288 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
335 ms |
4288 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
335 ms |
4288 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |