Advertisement
Guest User

LIS

a guest
Apr 12th, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. vector<int> d;
  5. int ans, n;
  6.  
  7. int main() {
  8.     scanf("%d", &n);
  9.     for (int i = 0; i < n; i++) {
  10.         int x;
  11.     scanf("%d", &x);
  12.         vector<int>::iterator it = upper_bound(d.begin(), d.end(), x);
  13.         if (it == d.end()) d.push_back(x);
  14.         else *it = x;
  15.     }
  16.     printf("LIS = %d", d.size());
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement