最长不增加子序列
#include <iostream>
using namespace std;
int d[100001], p[100001];
int main()
{
int n, m, len, max, i, j, z;
z = 1;
while ( cin >> m )
{
if( m == -1 )
{
break;
}
d[0] = m;
len = 1;
while ( cin >> m )
{
if( m == -1)
{
break;
}
d[len] = m;
len++;
}
p[0] = 1;
for( i = 1; i < len; i++)
{
p[i] = 1;
for( j = 0; j < i; j++)
{
if(d[i] <= d[j] && p[i] < p[j] + 1)
{
p[i] = p[j] + 1;
}
}
}
max = p[0];
for( i = 1; i < len; i++)
{
if( max < p[i])
{
max = p[i];
}
}
if( z != 1)
{
cout << endl;
}
cout << "Test #" << z << ":" << endl;
cout << " maximum possible interceptions: " ;
cout << max << endl;
z++;
}
return 0;
}