一维的动态,地址: http://acm.pku.edu.cn/JudgeOnline/problem?id=1887
#include
<
stdio.h
>
![](http://img.e-com-net.com/image/product/696412be261e44caa983ccc5cd2a1540.gif)
const
int
LEN
=
10001
;
![](http://img.e-com-net.com/image/product/696412be261e44caa983ccc5cd2a1540.gif)
int
num[LEN];
![](http://img.e-com-net.com/image/product/696412be261e44caa983ccc5cd2a1540.gif)
int
dp[LEN];
![](http://img.e-com-net.com/image/product/696412be261e44caa983ccc5cd2a1540.gif)
int
los (
int
n )
![](http://img.e-com-net.com/image/product/44df1c303f404ee184fdd8904c682a7f.gif)
{
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
dp[n-1] = 1;
for ( int i=n-2; i>=0; i-- )
![](http://img.e-com-net.com/image/product/16676c75a1f24c2286f9cfe3320175c2.gif)
{
int max = 0;
for ( int j=i+1; j<n; j++ )
![](http://img.e-com-net.com/image/product/16676c75a1f24c2286f9cfe3320175c2.gif)
{
if ( dp[j] > max && num[j] < num[i] )
![](http://img.e-com-net.com/image/product/16676c75a1f24c2286f9cfe3320175c2.gif)
{
max = dp[j];
}
}
dp[i] = max + 1;
}
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
int maxest = 0;
for ( i=0; i<n; i++ )
![](http://img.e-com-net.com/image/product/16676c75a1f24c2286f9cfe3320175c2.gif)
{
if ( dp[i] > maxest )
![](http://img.e-com-net.com/image/product/16676c75a1f24c2286f9cfe3320175c2.gif)
{
maxest = dp[i];
}
}
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
return maxest;
}
![](http://img.e-com-net.com/image/product/696412be261e44caa983ccc5cd2a1540.gif)
int
main ()
![](http://img.e-com-net.com/image/product/44df1c303f404ee184fdd8904c682a7f.gif)
{
int in;
int count = 0;
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
while ( scanf ( "%d", &in ) != EOF && in != -1 )
![](http://img.e-com-net.com/image/product/16676c75a1f24c2286f9cfe3320175c2.gif)
{
num[0] = in;
int n = 1;
while ( scanf ( "%d", &in ) != EOF && in != -1 )
![](http://img.e-com-net.com/image/product/16676c75a1f24c2286f9cfe3320175c2.gif)
{
num[n++] = in;
}
printf ( "Test #%d:\n maximum possible interceptions: %d\n\n", ++count, los ( n ) );
}
return 0;
}
![](http://img.e-com-net.com/image/product/696412be261e44caa983ccc5cd2a1540.gif)
![](http://img.e-com-net.com/image/product/696412be261e44caa983ccc5cd2a1540.gif)
![](http://img.e-com-net.com/image/product/696412be261e44caa983ccc5cd2a1540.gif)
![](http://img.e-com-net.com/image/product/696412be261e44caa983ccc5cd2a1540.gif)
![](http://img.e-com-net.com/image/product/696412be261e44caa983ccc5cd2a1540.gif)
![](http://img.e-com-net.com/image/product/696412be261e44caa983ccc5cd2a1540.gif)
![](http://img.e-com-net.com/image/product/696412be261e44caa983ccc5cd2a1540.gif)
![](http://img.e-com-net.com/image/product/696412be261e44caa983ccc5cd2a1540.gif)
![](http://img.e-com-net.com/image/product/696412be261e44caa983ccc5cd2a1540.gif)
![](http://img.e-com-net.com/image/product/44df1c303f404ee184fdd8904c682a7f.gif)
![](http://img.e-com-net.com/image/product/f6242890d71a40ab957c0cf10b55aac8.gif)
![](http://img.e-com-net.com/image/product/02d0904de3cc460eae11f6902a7115a2.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/16676c75a1f24c2286f9cfe3320175c2.gif)
![](http://img.e-com-net.com/image/product/d81fe41b31c2438aa82734253e0a4bcc.gif)
![](http://img.e-com-net.com/image/product/02d0904de3cc460eae11f6902a7115a2.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/16676c75a1f24c2286f9cfe3320175c2.gif)
![](http://img.e-com-net.com/image/product/d81fe41b31c2438aa82734253e0a4bcc.gif)
![](http://img.e-com-net.com/image/product/02d0904de3cc460eae11f6902a7115a2.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/16676c75a1f24c2286f9cfe3320175c2.gif)
![](http://img.e-com-net.com/image/product/d81fe41b31c2438aa82734253e0a4bcc.gif)
![](http://img.e-com-net.com/image/product/02d0904de3cc460eae11f6902a7115a2.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/4407806dd42e464c873774a6e93bb38f.gif)
![](http://img.e-com-net.com/image/product/4407806dd42e464c873774a6e93bb38f.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/4407806dd42e464c873774a6e93bb38f.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/16676c75a1f24c2286f9cfe3320175c2.gif)
![](http://img.e-com-net.com/image/product/d81fe41b31c2438aa82734253e0a4bcc.gif)
![](http://img.e-com-net.com/image/product/02d0904de3cc460eae11f6902a7115a2.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/16676c75a1f24c2286f9cfe3320175c2.gif)
![](http://img.e-com-net.com/image/product/d81fe41b31c2438aa82734253e0a4bcc.gif)
![](http://img.e-com-net.com/image/product/02d0904de3cc460eae11f6902a7115a2.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/4407806dd42e464c873774a6e93bb38f.gif)
![](http://img.e-com-net.com/image/product/4407806dd42e464c873774a6e93bb38f.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/91d69a26e7ce47d4bd97bff91bc3e9d1.gif)
![](http://img.e-com-net.com/image/product/696412be261e44caa983ccc5cd2a1540.gif)
![](http://img.e-com-net.com/image/product/696412be261e44caa983ccc5cd2a1540.gif)
![](http://img.e-com-net.com/image/product/44df1c303f404ee184fdd8904c682a7f.gif)
![](http://img.e-com-net.com/image/product/f6242890d71a40ab957c0cf10b55aac8.gif)
![](http://img.e-com-net.com/image/product/02d0904de3cc460eae11f6902a7115a2.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/16676c75a1f24c2286f9cfe3320175c2.gif)
![](http://img.e-com-net.com/image/product/d81fe41b31c2438aa82734253e0a4bcc.gif)
![](http://img.e-com-net.com/image/product/02d0904de3cc460eae11f6902a7115a2.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/16676c75a1f24c2286f9cfe3320175c2.gif)
![](http://img.e-com-net.com/image/product/d81fe41b31c2438aa82734253e0a4bcc.gif)
![](http://img.e-com-net.com/image/product/02d0904de3cc460eae11f6902a7115a2.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/4407806dd42e464c873774a6e93bb38f.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/4407806dd42e464c873774a6e93bb38f.gif)
![](http://img.e-com-net.com/image/product/58b5517de74d4214832479bcb515bf73.gif)
![](http://img.e-com-net.com/image/product/91d69a26e7ce47d4bd97bff91bc3e9d1.gif)
![](http://img.e-com-net.com/image/product/696412be261e44caa983ccc5cd2a1540.gif)