#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m; cin >> n >> m;
vector<int> v(n);
for(int i = 0; i<n; i++) cin >> v[i];
while(m--) {
int q; cin >> q;
if(q == 1) {
int pos, val; cin >> pos >> val;
v[pos - 1] = val;
}
else {
int cnt = 0, h; cin >> h;
for(int i = 0; i < n-1; i++) {
if(v[i] == h) {
cnt++;
}
else if(v[i] < h) {
if(v[i + 1] > h) cnt++;
}
else if(v[i] > h) {
if(v[i + 1] < h) cnt++;
}
}
if(v[n - 1] == h) cnt++;
cout << cnt << endl;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
212 KB |
Output is correct |
4 |
Correct |
4 ms |
212 KB |
Output is correct |
5 |
Correct |
4 ms |
212 KB |
Output is correct |
6 |
Correct |
4 ms |
308 KB |
Output is correct |
7 |
Correct |
4 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
212 KB |
Output is correct |
4 |
Correct |
4 ms |
212 KB |
Output is correct |
5 |
Correct |
4 ms |
212 KB |
Output is correct |
6 |
Correct |
4 ms |
308 KB |
Output is correct |
7 |
Correct |
4 ms |
212 KB |
Output is correct |
8 |
Execution timed out |
1089 ms |
1196 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
212 KB |
Output is correct |
4 |
Correct |
4 ms |
212 KB |
Output is correct |
5 |
Correct |
4 ms |
212 KB |
Output is correct |
6 |
Correct |
4 ms |
308 KB |
Output is correct |
7 |
Correct |
4 ms |
212 KB |
Output is correct |
8 |
Execution timed out |
1089 ms |
1196 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |