#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int lis(const vector<int>& v){
vector<int> d;
for (int x : d){
auto it = lower_bound(d.begin(), d.end(), x);
if (it == d.end()) d.push_back(x);
else *it = x;
}
return (int)d.size();
}
void solve() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int q;
vector<int> arr;
while (q--) {
int p, x;
cin >> p >> x;
int pos = max(0, p - 1);
if (pos > (int)arr.size()) pos = (int)arr.size();
arr.insert(arr.begin() + pos, x);
cout << lis(arr) << '\n';
}
}
int main() {
solve();
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |