#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
const int siz = 0;
const int mod = 0;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
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; int x; cin >> x;
for(int i=0; i<n-1; i++) {
if(v[i] == x) {
cnt++;
}
else if(v[i] < x) {
if(v[i+1] > x) cnt++;
}
else if(v[i] > x) {
if(v[i+1] < x) cnt++;
}
}
if(v[n-1] == x) cnt++;
cout << cnt << "\n";
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
336 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
3 ms |
340 KB |
Output is correct |
5 |
Correct |
3 ms |
344 KB |
Output is correct |
6 |
Correct |
3 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
336 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
3 ms |
340 KB |
Output is correct |
5 |
Correct |
3 ms |
344 KB |
Output is correct |
6 |
Correct |
3 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Execution timed out |
1079 ms |
1328 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 |
336 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
3 ms |
340 KB |
Output is correct |
5 |
Correct |
3 ms |
344 KB |
Output is correct |
6 |
Correct |
3 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Execution timed out |
1079 ms |
1328 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |