#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl "\n"
int mod=1e7+9;
const int N=1000005;//2e5+5;
template<class x>
using ordered_multiset = tree<x, null_type,less_equal<x>, rb_tree_tag,tree_order_statistics_node_update>;
int nm[N];
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n,m; cin>>n>>m;
int v[n];
for (int i=0;i<n;i++) cin>>v[i];
if (n<=1000) {
while (m--) {
int t; cin>>t;
if (t==1) {
int i,x; cin>>i>>x; i--;
v[i]=x;
}
else {
int h; cin>>h;
int ans=0;
for (int i=0;i+1<n;i++) {
if ((v[i]<h && v[i+1]>h) || (v[i]>h && v[i+1]<h)) ans++;
}
cout<<ans<<endl;
}
}
return 0;
}
for (int i=0;i+1<n;i++) {
nm[min(v[i],v[i+1])]++;
nm[max(v[i],v[i+1])]--;
}
for (int i=1;i<N;i++) {
nm[i]+=nm[i-1];
}
while (m--) {
int t,h; cin>>t>>h;
cout<<nm[h]<<endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
212 KB |
Output is correct |
5 |
Correct |
2 ms |
212 KB |
Output is correct |
6 |
Correct |
2 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
212 KB |
Output is correct |
5 |
Correct |
2 ms |
212 KB |
Output is correct |
6 |
Correct |
2 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
28 ms |
9068 KB |
Output is correct |
9 |
Correct |
38 ms |
9380 KB |
Output is correct |
10 |
Correct |
41 ms |
9420 KB |
Output is correct |
11 |
Correct |
27 ms |
9044 KB |
Output is correct |
12 |
Correct |
32 ms |
9456 KB |
Output is correct |
13 |
Correct |
36 ms |
9432 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
212 KB |
Output is correct |
5 |
Correct |
2 ms |
212 KB |
Output is correct |
6 |
Correct |
2 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
28 ms |
9068 KB |
Output is correct |
9 |
Correct |
38 ms |
9380 KB |
Output is correct |
10 |
Correct |
41 ms |
9420 KB |
Output is correct |
11 |
Correct |
27 ms |
9044 KB |
Output is correct |
12 |
Correct |
32 ms |
9456 KB |
Output is correct |
13 |
Correct |
36 ms |
9432 KB |
Output is correct |
14 |
Incorrect |
39 ms |
9420 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |