程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> 關於C語言 >> 10901 Missile

10901 Missile

編輯:關於C語言

10901 Missile

時間限制:1000MS  內存限制:65535K
提交次數:40 通過次數:7

Description

Long, long ago, country A invented a missile system to destroy the missiles from their enemy. That system can launch only one missile to destroy multiple missiles if the heights of all the missiles form a non-decrease sequence.

But recently, the scientists found that the system is not strong enough. So they invent another missile system. The new system can launch one single missile to destroy many more enemy missiles. Basically, the system can destroy the missile from near to far. When the system

is begun, it chooses one enemy missile to destroy, and then destroys a missile whose height is lower and farther than the first missile. The third missile to destroy is higher and farther than the second missile... the odd missile to destroy is higher and farther than the previous one, and the even missile to destroy is lower and farther than the previous one.

Now, given you a list of the height of missiles from near to far, please find the most missiles that can be destroyed by one missile launched by the new system.

輸入格式

The input contains multiple test cases.

In each test case, first line is an integer n (0<n≤1000), which is the number of missiles to destroy. Then follows one line which contains n integers (≤109), the height of the missiles followed by distance.

The input is terminated by n=0.

輸出格式

For each case, print the most missiles that can be destroyed in one line.

輸入樣例

4
5 3 2 4
3
1 1 1
0

輸出樣例

3
1

題意:

  n代表導彈數目,然後從高到遠給出導彈的高度,

  求最多能打下導彈個數,比且打下來的第偶數個導彈要比前一個矮且遠,第奇數個導彈要比前一個

  高且遠。

 
DP題:


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved