50 lines
1.1 KiB
C++
50 lines
1.1 KiB
C++
|
|
#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() {
|
||
|
|
freopen("sort.in","r",stdin);
|
||
|
|
freopen("sort.out","w",stdout);
|
||
|
|
|
||
|
|
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;//id
|
||
|
|
//这句话
|
||
|
|
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;
|
||
|
|
}
|