最長上公升子串行 oj

2021-08-15 14:21:50 字數 1054 閱讀 9347

time limit: 3000 ms

memory limit: 65536 kib

submit

statistic

problem description

乙個數的序列bi,當b

1< b

2< ... < b

s的時候,我們稱這個序列是上公升的。對於給定的乙個序列(a

1, a

2, ..., a

n),我們可以得到一些上公升的子串行(a

i1, a

i2, ..., a

ik),這裡1<= i

1< i

2< ... < i

k<= n。比如,對於序列(1, 7, 3, 5, 9, 4, 8),有它的一些上公升子串行,如(1, 7), (3, 4, 8)等等。這些子串行中最長的長度是4,比如子串行(1, 3, 5, 8)。

你的任務,就是對於給定的序列,求出最長上公升子串行的長度。

input

輸入的第一行是序列的長度n (1 <= n <= 1000)。第二行給出序列中的n個整數,這些整數的取值範圍都在0到10000。

output

最長上公升子串行的長度。

sample input

7

1 7 3 5 9 4 8

sample output

4

hint

source

northeastern europe 2002#include #include #include #include #define n 2000

int b[n];

int max[n];

int main()

{ int n,m,i,j;

scanf("%d",&n);

for(i = 1;i<=n;i++)

scanf("%d",&b[i]);

max[1] =1;

for(i=2;i<=n;i++)

{m = 0;

for(j=1;jb[j])

if(m

最長上公升子串行 OJ

最長上公升子串行 time limit 3000 ms memory limit 65536 kib submit statistic problem description 乙個數的序列bi,當b1 b2 bs的時候,我們稱這個序列是上公升的。對於給定的乙個序列 a1,a2,an 我們可以得到一些...

最長上公升子串行

問題描述 乙個數的序列bi,當b1 b2 bs的時候,我們稱這個序列是上公升的。對於給定的乙個序列 a1,a2,an 我們可以得到一些上公升的子串行 ai1,ai2,aik 這裡1 i1 i2 ik n。比如,對於序列 1,7,3,5,9,4,8 有它的一些上公升子串行,如 1,7 3,4,8 等等...

最長上公升子串行

最長上公升子串行問題是各類資訊學競賽中的常見題型,也常常用來做介紹動態規劃演算法的引例,筆者接下來將會對poj上出現過的這類題目做乙個總結,並介紹解決lis問題的兩個常用 演算法 n 2 和 nlogn 問題描述 給出乙個序列a1,a2,a3,a4,a5,a6,a7.an,求它的乙個子串行 設為s1...