Cod sursa(job #2133481)
| Utilizator | Data | 17 februarie 2018 00:16:35 | |
|---|---|---|---|
| Problema | Subsir crescator maximal | Scor | 35 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.71 kb |
//#include <iostream>
#include <fstream>
using namespace std;
ifstream f("scmax.in");
ofstream cout("scmax.out");
int n, a[100005], viz[100005], best[100005], lmax, k, poz;
int main()
{
int i, j;
f>>n;
for (i=1; i<=n; i++) f>>a[i];
best[n]=1; viz[n]=-1;
lmax=1; poz=n;
for (i=n-1; i>=1; i--)
{
best[i]=1;
viz[i]=-1;
for (j=i+1; j<=n; j++)
if (a[i]<a[j] && best[i]<best[j]+1)
{
best[i]=best[j]+1;
viz[i]=j;
if (best[i]>lmax)
{
lmax=best[i];
poz=i;
}
}
}
cout<<lmax<<"\n";
return 0;
}
