Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- int v[1000],n,i;
- cout<<"n=";cin>>n;
- for (i=0;i<n;i++)
- {
- cout<<"v["<<i<<"]=";cin>>v[i];
- }
- vector<vector<int> > L(n);
- L[0].push_back(v[0]);
- for (int i = 1; i < n; i++)
- {
- for (int j = 0; j < i; j++)
- {
- if ((v[i] > v[j]) &&(L[i].size() < L[j].size() + 1))
- L[i] = L[j];
- }
- L[i].push_back(v[i]);
- }
- vector<int> maxi = L[0];
- for (vector<int> x : L)
- if (x.size() > maxi.size())
- maxi = x;
- for (auto x : maxi)
- cout << x << " ";
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement