//////////////////////////////////////// //////////////////
// Fatmouse's speed: the slower the white mouse grows.
// Use DP, similar to the DNA sequence
# Include <iostream>
Using namespace STD;
Int st [1001] [2], output [1001];
Class mouse
{
Public:
Int size;
Int speed;
Int no;
Bool operator <= (Mouse)
{
Return (size <= A. size );
}
};
//////////////////////////////////////// ///////////////////
Template <class type>
Void Merge (Type C [], type D [], int L, int M, int R)
{
Int I = L, j = m + 1, K = L, Q;
While (I <= m) & (j <= r ))
{
If (C [I] <= C [J])
D [k ++] = C [I ++];
Else
D [k ++] = C [J ++];
}
If (j> r)
For (q = I; q <= m; q ++)
D [k ++] = C [Q];
Else
For (q = J; q <= r; q ++)
D [k ++] = C [Q];
}
//////////////////////////////////////// ////////////////////
Template <class type>
Void mergepass (Type X [], Type Y [], int S, int N)
{
Int J, I = 0;
While (I + 2 * S <= N)
{
Merge (X, Y, I, I + s-1, I + 2 * s-1 );
I + = 2 * s;
}
If (I + S <n)
Merge (X, Y, I, I + s-1, n-1 );
Else
For (j = I; j <n; j ++)
Y [J] = x [J];
}
//////////////////////////////////////// ////////////////////
Template <class type>
Void mergesort (type A [], int N)
{
Type * B = new type [N];
Int S = 1;
While (S <n)
{
Mergepass (A, B, S, N );
S * = 2;
Mergepass (B, A, S, N );
S * = 2;
}
}
//////////////////////////////////////// ///////////////////////
Mouse mice [1001];
Int main ()
{
Int I, j, Len, maxlever, Max, post, State;
Mice [0]. size = 0;
Mice [0]. speed = 20000;
Mice [0]. No = 0;
I = 1;
While (CIN> mice [I]. Size )! = 0)
{
Cin> mice [I]. speed;
Mice [I]. No = I;
I ++;
}
Len = I; // This length is not the original length and increases the mice [0].
Mergesort (mice, Len );
St [0] [0] =-1;
St [0] [1] = 0;
For (I = 1; I <Len; I ++)
{
Maxlever =-1;
For (j = 0; j <I; j ++)
{
If (mice [I]. size> mice [J]. size & mice [I]. speed <mice [J]. speed & St [J] [1]> maxlever)
{// The sequence must increase or decrease
Maxlever = sT [J] [1];
State = J;
}
}
St [I] [1] = maxlever + 1;
St [I] [0] = State;
}
Post = 0;
Max = 0;
For (I = 1; I <Len; I ++)
If (max <st [I] [1])
{
Max = sT [I] [1];
Post = I;
}
I = 0;
While (post! = 0)
{
Output [I] = mice [Post]. No;
Post = sT [Post] [0];
I ++;
}
Cout <max <Endl;
For (j = I-1; j> = 0; j --)
Cout <output [J] <Endl;
Return 0;
}