Cod sursa(job #1366533)
| Utilizator | Data | 1 martie 2015 10:50:59 | |
|---|---|---|---|
| Problema | Subsir crescator maximal | Scor | 5 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.6 kb |
#include <iostream>
#include <fstream>
using namespace std;
const int nmax=100001;
int n,a[nmax],best[nmax];
void citire()
{
ifstream fin("scmax.in");
fin>>n;
for(int i=1;i<=n;++i)
fin>>a[i];
}
void subsir2()
{
ofstream fout("scmax.out");
int bmax=0;
best[n]=1;
for(int i=n-1;i>=1;--i)
for(int j=i+1;j<=n;++j)
if(a[i]<a[j] && best[i]<=best[j])
best[i]=best[j]+1;
for(int i=1;i<=n;++i)
if(bmax<best[i])
bmax=best[i];
fout<<bmax;
}
int main()
{
citire();
subsir2();
return 0;
}
