#include <bits/stdc++.h>
#include <fstream>
#define endl '\n'
#define mod 1000007
#define INF 1000000000000000000
//#define ll long long
///#define cin fin
///#define cout fout
#define fi first
#define se second
using namespace std;
double const EPS = 1e-14;
///ofstream fout("herding.out");
///ifstream fin("herding.in");
const int Max = 1e6 + 5;
const int M = 1e6;
int cnt[Max];
int main()
{
ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
int n, m; cin >> n >> m; int arr[n];
for(int i = 0; i < n; i++) cin >> arr[i];
for(int i = 1; i < n; i++) {
if(arr[i-1] < arr[i]) {
cnt[arr[i-1]]++;
cnt[arr[i]+1]--;
}
else {
cnt[arr[i-1]]--;
cnt[arr[i]+1]++;
}
}
for(int i = 1; i <= M; i++) {
cnt[i] += cnt[i-1];
}
while(m--) {
int ty; cin >> ty;
if(ty == 1) {
int pos, val; cin >> pos >> val;
arr[pos-1] = val;
}
else {
int h; cin >> h;
cout << cnt[h] << endl;
}
}
return 0;
}
/*3 3
1 5 1
2 3
1 1 5
2 3*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
4180 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
4180 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
4180 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |