Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- vector <int> elementi;
- for(int i = 0; i < n; i++)
- {
- int x;
- cin >> x;
- elementi.push_back(x);
- }
- vector <int> kuli;
- for(int i = 0; i < n; i++)
- {
- int indeks = lower_bound(kuli.begin(), kuli.end(), elementi[i] + 1) - kuli.begin();
- if(indeks >= 0 and indeks < kuli.size()) {
- kuli[indeks] = elementi[i];
- }
- else {
- kuli.push_back(elementi[i]);
- }
- }
- cout << kuli.size() << endl;
- return 0;
- }
- // 3 8 2 1 5
- // kuli: 3 8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement