Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #define nmax 1005
- //NU UITA SA MODIFICI DATELE, NMAX SI .in .out
- using namespace std;
- ifstream f("subsiruri.in");
- ofstream g("subsiruri.out");
- int l[nmax], a[nmax], n, lmax, nr[nmax], poz, nr2;
- int main()
- {
- int i, j, max;
- f>>n;
- for(i=1;i<=n;++i) f>>a[i];
- l[n]=1;
- for(i=n-1;i>=1;--i)
- {
- max=nr2=0;
- for(j=i+1;j<=n;++j)
- if(l[j]>max && a[j]>a[i])
- max=l[j];
- for(j=i+1;j<=n;++j) if(l[i]==max) ++nr2;
- nr[i]=nr[i-1]+nr2;
- l[i]=max+1;
- if(l[i]>lmax)
- {
- lmax=l[i];
- poz=i;
- }
- }
- //for(i=1;i<=n;++i)
- //g<<l[i]<<" ";
- g<<nr[1];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement