首页 > 代码库 > POJ2533

POJ2533

POJ2533

 

#include <STDIO.H>
#include <MALLOC.H>

#define max(a, b) (((a) > (b)) ? (a) : (b))
void GetMaxIncLen(int *data, int *maxLen, int size)
{
int i, j;
for(i = 2; i <= size; i++)
{
for(j = 1; j < i; j++)
{
if(data[j] < data[i])
{
maxLen[i] = max(maxLen[i], maxLen[j] + 1);
}
}
}
}

void main()
{
int i, size, max;
int *data = http://www.mamicode.com/NULL;
int *maxLen = NULL;
scanf("%d", &size);
data = http://www.mamicode.com/(int *)malloc(sizeof(int) * (size > maxLen = (int *)malloc(sizeof(int) * (size + 1));
memset(data, 0, sizeof(int) * (size + 1));
memset(maxLen, 0, sizeof(int) * (size + 1));
for(i = 1; i <= size; i++)
{
scanf("%d", &data[i]);
maxLen[i] = 1;
}


GetMaxIncLen(data, maxLen, size);
max = 0;
for(i = 1; i <= size; i++)
{
if(maxLen[i] > max)
{
max = maxLen[i];
}
}
printf("%d", max);

}