Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int arr[]={5,4,-3,1,7,2,3,-20};
- int sol[10];
- vector<int>v[10];
- sol[0]=1;
- for(int i=1; i<8; i++)
- {
- sol[i]=1;
- for(int j=0; j<i; j++)
- {
- if(arr[i]> arr[j] && sol[i] < sol[j]+1)
- {
- sol[i] = sol[j]+1;
- v[i].push_back(arr[j]);
- }
- }
- v[i].push_back(arr[i]);
- }
- int m=sol[0],h;
- for(int j=1; j<8; j++)
- {
- printf("%d ", sol[j]);
- if(sol[j]>m){
- m=sol[j];
- h=j;
- }
- }
- printf("\n");
- for(int j=0;j<v[h].size();j++){
- printf("%d ",v[h][j]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement