// ignore my subtask bashing :)
#include <bits/stdc++.h>
using ll = long long;
std::vector<int> countScans(std::vector<int> a, std::vector<int> x, std::vector<int> v) {
const int n = a.size();
const int q = x.size();
std::vector<int> res(q);
for (int t = 0; t < q; t++) {
a[x[t]] = v[t];
std::multiset<int> cur;
for (int i : a) {
auto it = cur.upper_bound(i);
if (it == cur.begin()) {
cur.insert(i);
} else {
--it;
cur.erase(it);
cur.insert(i);
}
}
res[t] = cur.size() - 1;
}
return res;
}
/*
int main() {
auto res = countScans({1, 2, 3, 4}, {0, 2}, {3, 1});
for (int i : res) std::cout << i << ' ';
}
*/