fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int x[100005],ind = -1;
  7. set<int>st;set<int>::iterator it;
  8. int TC;
  9. cin >> TC;
  10. while (TC--)
  11. {
  12. int N;
  13. cin >> N;
  14. for(int i=0;i<N;i++)
  15. {
  16. cin >> x[i];
  17. st.insert(x[i]);
  18. it = st.find(x[i]);
  19. it++;
  20. if (it!= st.end())st.erase(it);
  21. }
  22. cout <<st.size() <<"\n";
  23. // cout <<"-\n";
  24. // for(it =st.begin();it!=st.end();it++)cout <<*it << "\n";
  25. }
  26. }
Success #stdin #stdout 0s 3732KB
stdin
2
5
7 7 2 11 7
10
9 1 7 6 9 9 8 7 6 7
stdout
2
3