导弹拦截 怎么改
pascal吧
全部回复
仅看楼主
level 10
syuku33 楼主
var
a,b:array[0..10000] of longint;
n,i,j,max:longint;
begin
fillchar(b,sizeof(b),0);
read(n);
for i:=1 to n do read(a[i]);
for i:=1 to n do b[i]:=1;
for i:=2 to n do
for j:=1 to i-1 do
if (a[i]<=a[j]) and (b[j]+1>b[i]) then b[i]:=b[j]+1;
max:=0;
for i:=1 to n do if b[i]>max then max:=b[i];
write(max,' ');
for i:=2 to n do
for j:=1 to i-1 do
if (a[i]>a[j]) and (b[j]+1>b[i]) then b[i]:=b[j]+1;
max:=0;
for i:=1 to n do if b[i]>max then max:=b[i];
writeln(max);
end.
2015年04月25日 07点04分 1
level 3
题目是什么
2015年04月25日 09点04分 2
level 10
syuku33 楼主
导弹拦截
某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统。但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能高于前一发的高度。某天,雷达捕捉到敌国的导弹来袭。由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹。
输入格式:
输入数据为两行,
第一行为导弹的数目N
第二行导弹依次飞来的高度,所有高度值均为不大于30000的正整数。
输出格式:
输出只有一行是这套系统最多能拦截的导弹数和要拦截所有导弹最少要配备这种导弹拦截系统的套数。两个数据之间用一个空格隔开.
样例输入:
样例输出:
数据范围:
n<=100000
时间限制:
1S
空间限制:
256M
提示:
DP
2015年04月25日 10点04分 3
2015年04月25日 10点04分
1