Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(a[m] < val)
- ini = m;
- else
- fin = m, pos = min(pos, m);
- }
- if(a[ini] >= val)
- pos = min(pos, ini);
- if(a[fin] >= val)
- pos = min(pos, fin);
- return pos;
- }
- ll longestIncreasingSubsequence()
- {
- LIS = 0, a[0] = v[0];
- for1(i, (n - 1))
- {
- if(v[i] < a[0])
- a[0] = v[i];
- else if(v[i] > a[LIS])
- LIS++, a[LIS] = v[i];
- else
- a[ceilBinario(v[i])] = v[i];
- }
- return (LIS + 1);
- }
- int main()
- {
- ios::sync_with_stdio(false);
- cin.tie(NULL);
- cin >> n;
- forn(i, n)
- cin >> v[i];
- cout << longestIncreasingSubsequence() << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement