You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
949 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
const int N = 8010;
struct Node {
int id, value;
bool operator<(const Node &t) const {
if (value == t.value) return id < t.id;
return value < t.value;
}
} a[N];
vector<Node> f;
int n, q;
int main() {
cin.tie(0), ios::sync_with_stdio(false);
cin >> n >> q;
for (int i = 1; i <= n; i++) {
cin >> a[i].value;
a[i].id = i;
f.insert(lower_bound(f.begin(), f.end(), a[i]), a[i]);
}
int op, x, v;
while (q--) {
cin >> op;
if (op == 1) {
cin >> x >> v;
f.erase(lower_bound(f.begin(), f.end(), a[x]));
a[x].value = v;
f.insert(lower_bound(f.begin(), f.end(), a[x]), a[x]);
} else {
cin >> x;
printf("%d\n", lower_bound(f.begin(), f.end(), a[x]) - f.begin() + 1);
}
}
return 0;
}