#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
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";
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |