Pagini recente » Cod sursa (job #2862794) | Cod sursa (job #577863) | Cod sursa (job #1477356) | Cod sursa (job #2123172) | Cod sursa (job #1168657)
//#include "stdafx.h"
#include "fstream"
#include <stdio.h>
using namespace std;
long long vector[100000];
int best[100000];
int a[100000];
long long sol[100000];
int main()
{
ifstream f("scmax.in");
ofstream g("scmax.out");
//while(!f.eof())
//{
int i,n,ind,max,maxbest,indmax,j;
f>>n;
for(i=1;i<=n;i++)
f>>vector[i];
best[1]=1;
maxbest=1;
a[0]=-1;
ind=1;
for(i=2;i<=n;i++)
{
max=0;
for(j=i-1;j>=1;j--)
if(vector[i]>vector[j]&&best[j]>max)
{
max=best[j];
ind=j;
}
best[i]=max+1;
a[i]=ind;
if(vector[i]<=vector[ind])
{
best[i]=1;
a[i]=-1;
}
if(maxbest<best[i])
{
maxbest=best[i];
indmax=i;
}
}
g<<maxbest;
//}
return 0;
}