Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define NMAX 1005
- using namespace std;
- ifstream f ("sclm.in");
- ofstream g ("sclm.out");
- int n;
- int a[NMAX] , b[NMAX];
- int main()
- {
- int i , j , maxi = 0 , lgmax = 0 , poz = 0;
- f >> n;
- for(i=1;i<=n;i++)
- f >> a[i];
- b[n] = 1;
- for(i=n-1;i>=1;i--)
- {
- maxi = 0;
- for(j=i+1;j<=n;j++)
- if(a[i] <= a[j] && b[j] > maxi)
- maxi = b[j];
- b[i] = maxi + 1;
- if(lgmax <= b[i])
- {
- lgmax = b[i];
- poz = i;
- }
- }
- g << lgmax << '\n';
- for(i=poz;i<=n;i++)
- {
- if(b[i] == lgmax)
- {
- g << i << ' ';
- lgmax--;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement