Pagini recente » Cod sursa (job #263381) | Cod sursa (job #779154) | Cod sursa (job #867167) | Cod sursa (job #2712157) | Cod sursa (job #1169010)
//#include "stdafx.h"
#include "fstream"
using namespace std;
long long Vector[100005];
int VMaxim[100005];
int UseableElem[100005];
int main()
{
ifstream f("6.in");
ofstream g("6.out");
int i , Pozition , Max , MaxBest , PozMax , j;
int a;
for(int NrElem ; f>>NrElem;)
{
for(i=1;i<=NrElem;i++)
f>>Vector[i];
VMaxim[1]=1;
MaxBest=1;
UseableElem[0]=-1;
Pozition=1;
for(i=2;i<=NrElem;i++)
{
Max=0;
for(j=i-1;j>=1;j--)
if(Vector[i]>Vector[j]&&VMaxim[j]>Max)
{
Max=VMaxim[j];
Pozition=j;
}
VMaxim[i]=Max+1;
UseableElem[i]=Pozition;
if(Vector[i]<=Vector[Pozition])
{
VMaxim[i]=1;
UseableElem[i]=-1;
}
if(MaxBest<VMaxim[i])
{
MaxBest=VMaxim[i];
PozMax=i;
}
}
g<<MaxBest<<"\n";
}
return 0;
}