Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- int T;
- cin >> T;
- while(T--) {
- int N;
- cin >> N;
- vector < int > a(N), deck;
- for(int& x : a)
- cin >> x;
- for(int x : a) {
- if(deck.empty()) {
- deck.emplace_back(x);
- continue;
- }
- if(x > deck.back()) {
- deck.emplace_back(x);
- continue;
- }
- auto it = lower_bound(deck.begin(), deck.end(), x);
- *it = x;
- }
- cout << deck.size() << '\n';
- }
- }
Add Comment
Please, Sign In to add comment