CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • February CookOff
    • February Long Contest
    • January CookOff
  • DISCUSS
    • Wiki
    • Forums
    • Blog
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
    • Event Calendar
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Ranks
    • Tutorials
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » Craft 2010 » Destroy the Enemy

Destroy the Enemy

Problem code: CRAFT02

  • All Submissions

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


  • Submit

Comments

  • Login or Register to post a comment.

can anybody tell something

cybersharp @ 10 Mar 2010 03:43 PM

can anybody tell something about this competition??

@ Craft 2010 :::: CRAFTALG

vish @ 10 Mar 2010 10:19 PM

@ Craft 2010 :::: CRAFTALG

where to register for this contest ??

its a practice contest or real contest???

can any body elloborate the

dabbcomputers @ 10 Mar 2010 10:26 PM

can any body elloborate the test cases pls...

is the range of missile and

dabbcomputers @ 10 Mar 2010 11:22 PM

is the range of missile and destruction radius both are same??

input ends with 1 or -1 ?

dejavu @ 11 Mar 2010 01:43 AM

input ends with 1 or -1 ?

This is a real contest and is

amanatadmin @ 11 Mar 2010 10:37 AM

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

amanatadmin @ 11 Mar 2010 10:38 AM

inputs ends with

-1 -1

NO need to worry about the

amanatadmin @ 11 Mar 2010 10:39 AM

NO need to worry about the range as all are within the range as mentioned in the question

can anyone explain the first

gaurav17 @ 11 Mar 2010 02:50 PM

can anyone explain the first test case with d=0?

what are x1, x2, xi, xn??

mcsharma1990 @ 11 Mar 2010 05:41 PM

what are x1, x2, xi, xn??

when you say input end with

alok @ 11 Mar 2010 08:11 PM
when you say input end with D=n=-1, is it possible that our submission will be tested against cases with D= -1 and n!= -1 ?

Or vice-versa. Or is it

alok @ 11 Mar 2010 08:15 PM

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

amanatadmin @ 12 Mar 2010 01:13 AM

@Lucky: No it is clearly mentioned that the input ends with -1 -1

@Mahesh Chandra

amanatadmin @ 12 Mar 2010 01:15 AM

@Mahesh Chandra Sharma:x1,x2...xi....xn are the assumed x co-ordinates

can anyone explain the test

rohitkg @ 12 Mar 2010 02:00 AM

can anyone explain the test cases, please...

hmmmm

mohan krishna @ 13 Mar 2010 06:23 PM

hmmmm

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold
CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of computer programming. At CodeChef we work hard to revive the geek in you by hosting programming contests on a monthly basis. We also aim to have training sessions and events related to online programming for programmers around the world. Apart from providing a platform for programming competitions, CodeChef also has various tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our judge accepts solutions in over 35+ programming languages. Online programming was never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming competitions that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly programming contests and the shorter format Cook-off programming contests. Put yourself up for recognition and win great prizes. Prizes worth up to Rs.20,000 and $700 are up for grabs every month along with lots more CodeChef goodies.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be part of CodeChefs Forums and interact with all our programmers love helping out other programmers and share their ideas.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. Be a part of the CodeChef community through CodeChef meetups and techtalks. You can also host a programming contest for your institute on CodeChef and be a guest author on our blog.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com