Pagini recente » Cod sursa (job #1212545) | Cod sursa (job #1666845) | Cod sursa (job #2169798) | Profil UTCN_Balint_Petrican_Suciu | Cod sursa (job #534614)
Cod sursa(job #534614)
#include<stdio.h>
//#include<Windows.h>
#define MAX 5010
long long n,v[MAX],best[MAX],rec[MAX];
int FndMax(int pos)
{
int a,max=-2000000;
a=pos;
rec[a]=-1;
while(pos)
{
if(max<v[pos] && v[pos]< v[a])
rec[a]=pos;
--pos;
}
return rec[a];
}
int main()
{
int i,j;
// SetPriorityClass(GetCurrentProcess(),256);
freopen("subsir2.in","r",stdin);
freopen("subsir2.out","w",stdout);
scanf("%d",&n);
for(i=0;i<n;++i)
scanf("%d",v+i);
int max=-1000002;
for(i=0;i<n;++i)
{
best[i]=1+best[FndMax(i)];
if(max<best[i])
max=best[i];
}
//reconstr sol
printf("%d",max);
return 0;
}