Destroy the EnemyProblem code: CRAFT02 |
A war is going on between two countries. You are the military head and got information from intelligence about the positions of the enemy troops. You have the missiles and when they hit the target they create a destruction in a region of radius D. Assume that the y coordinate of all the troops is same and have different x co-ordinates as x1,x2, xi, xn. Also assume that all troops are in the range of our missile and the missile can only be targeted to one of the troops. You need to destruct the enemy force by using minimum number of missiles.
Input
The input test file will contain multiple cases. Each test case begins with a single line containing an integer D, the maximum effective range of all missiles (where 0 D 100), and an integer n, the number of troops of the enemy (where 1 n 100). The next line contains n integers, indicating the positions x1,x2, xi, xn of each troop (where 0 xi 100). The end-of-input is marked by a test case with D = n = 1.
Output
For each test case, print a single integer indicating the minimum number of missiles needed.
Example
Input: 0 3 10 20 20 10 7 70 30 1 7 15 20 50 -1 -1 Output: 2 4
| Date: | 2010-03-04 |
| Time limit: | 30s |
| Source limit: | 50000 |
| Languages: | C C99 strict C++ 4.0.0-8 C++ 4.3.2 PAS gpc PAS fpc JAVA NICE JAR C# C#2 NEM ST ASM D FORT ADA BASH PERL PYTH RUBY LUA ICON PIKE PHP SCM guile SCM qobi LISP sbcl LISP clisp SCALA HASK ERL CAML CLPS PRLG WSPC BF ICK JS |
Comments

Fetching successful submissions

can anybody tell something
can anybody tell something about this competition??
@ Craft 2010 :::: CRAFTALG
@ Craft 2010 :::: CRAFTALG
where to register for this contest ??
its a practice contest or real contest???
can any body elloborate the
can any body elloborate the test cases pls...
is the range of missile and
is the range of missile and destruction radius both are same??
input ends with 1 or -1 ?
input ends with 1 or -1 ?
This is a real contest and is
This is a real contest and is a part of Technical fest NIMBUS '10 of NIT Hamirpur.
You can submit your solutions direcly if you have an account here
inputs ends with -1 -1
inputs ends with
-1 -1
NO need to worry about the
NO need to worry about the range as all are within the range as mentioned in the question
can anyone explain the first
can anyone explain the first test case with d=0?
what are x1, x2, xi, xn??
what are x1, x2, xi, xn??
when you say input end with
Or vice-versa. Or is it
Or vice-versa. Or is it mandatory to put both n=-1 and d= -1 togather because if not, then are you testing for cases like d=-1, n=3 ?
@Lucky: No it is clearly
@Lucky: No it is clearly mentioned that the input ends with -1 -1
@Mahesh Chandra
@Mahesh Chandra Sharma:x1,x2...xi....xn are the assumed x co-ordinates
can anyone explain the test
can anyone explain the test cases, please...
hmmmm
hmmmm