// left to right increase order

for(seqIndex=0;seqIndex<size;seqIndex++){

incOrder[seqIndex]=1;

for(int i=seqIndex-1;i>=0;i--){

if(seq

*== seq[seqIndex]-1 && incOrder[seqIndex] < incOrder*

*+1){*

incOrder[seqIndex]=incOrderincOrder[seqIndex]=incOrder

*+1;*

break;

}

if(seqbreak;

}

if(seq

*< seq[seqIndex] && incOrder[seqIndex] < incOrder**+1){*

incOrder[seqIndex]=incOrderincOrder[seqIndex]=incOrder

*+1;*

}

}

}

// right to left increase order (namely decrease order)

int max=INT_MIN;

for(seqIndex=size-1;seqIndex>=0;seqIndex--){

decOrder[seqIndex]=1;

for(int i=seqIndex+1;i<size;i++){

if(seq}

}

}

// right to left increase order (namely decrease order)

int max=INT_MIN;

for(seqIndex=size-1;seqIndex>=0;seqIndex--){

decOrder[seqIndex]=1;

for(int i=seqIndex+1;i<size;i++){

if(seq

*== seq[seqIndex]-1 && decOrder[seqIndex] < decOrder**+1){*

decOrder[seqIndex]=decOrderdecOrder[seqIndex]=decOrder

*+1;*

break;

}

if(seqbreak;

}

if(seq

*< seq[seqIndex] && decOrder[seqIndex] < decOrder[i]+1){*

decOrder[seqIndex]=decOrder[i]+1;

}

}

// find max value.

if(decOrder[seqIndex]==incOrder[seqIndex] && max<decOrder[seqIndex]){

max=decOrder[seqIndex];

}

}[/cpp]

It's my core code. But it is O(n^2). So I can't escape from TLE.

I have to think more...decOrder[seqIndex]=decOrder[i]+1;

}

}

// find max value.

if(decOrder[seqIndex]==incOrder[seqIndex] && max<decOrder[seqIndex]){

max=decOrder[seqIndex];

}

}[/cpp]

It's my core code. But it is O(n^2). So I can't escape from TLE.

I have to think more...