Counting Quadrangles

C

chenxinhlj

Description
a hero invented a new style of cross-bow that could shoot
consecutively. The arrow could hit the eagle exactly if only the arrow
could reach the height of the eagle. However, there was a flaw of the
corss-bow: only the first arrow could reach any height and the height
that the arrow shot latter could reach was always lower than the
former one. Actually, the higher the cross-bow can hit, the better the
performance it is. One day, the hero happened to see a crowd of eagles
flying through the sky. Now you have to work out a program that helps
Guo Jing to count how many eagles he can shoot down at most.
Input
This problem contains multiple test cases. For each test case, input
the number of eagles n (1<=n<=1000) in the first line, then input the
height h of each eagle (1<=h<=10000) in another new line with a blank
between every two of them.
Output
Please calculate the maximal number of eagles m that can be shot down
by the cross-bow in the first line, and then output the height of the
each eagle that have been shot down and separated by blanks in the
second line.
Sample Input
8
389 207 155 300 299 170 158 65
2
100 105

Sample Output
6
389 300 299 170 158 65
1
105
 
P

Peter Pichler

(e-mail address removed) wrote:

[something that looked like a homework assignment]

And your C question is...?
 
M

Malcolm McLean

Description
a hero invented a new style of cross-bow that could shoot
consecutively. The arrow could hit the eagle exactly if only the arrow
could reach the height of the eagle. However, there was a flaw of the
corss-bow: only the first arrow could reach any height and the height
that the arrow shot latter could reach was always lower than the
former one. Actually, the higher the cross-bow can hit, the better the
performance it is. One day, the hero happened to see a crowd of eagles
flying through the sky. Now you have to work out a program that helps
Guo Jing to count how many eagles he can shoot down at most.
Input
This problem contains multiple test cases. For each test case, input
the number of eagles n (1<=n<=1000) in the first line, then input the
height h of each eagle (1<=h<=10000) in another new line with a blank
between every two of them.
Output
Please calculate the maximal number of eagles m that can be shot down
by the cross-bow in the first line, and then output the height of the
each eagle that have been shot down and separated by blanks in the
second line.
Sample Input
8
389 207 155 300 299 170 158 65
2
100 105

Sample Output
6
389 300 299 170 158 65
1
105
Hint.
Think what to do if you have one eagle left. The two, then three, then four.
Work backwards until you decide whether to shoot the first eagle or not.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,001
Messages
2,570,254
Members
46,851
Latest member
CliftonCor

Latest Threads

Top