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
    • All Contests
    • June Long 2012
    • May Cook-Off
    • May Long 2012
  • DISCUSS
    • Forums
    • Blog
    • Wiki
    • Facebook
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
    • Event Calendar
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Practice(easy) » Birthday Candles

Birthday Candles

Problem code: CANDLE

  • Submit
  • All Submissions

All submissions for this problem are available.

The chef is preparing a birthday cake for one of his guests, and his decided to write the age of the guest in candles on the cake. There are 10 types of candles, one for each of the digits '0' through '9'. The chef has forgotten the age of the guest, however, so doesn't know whether he has enough candles of the right types. For example, if the guest were 101 years old, the chef would need two '1' candles and one '0' candle. Given the candles the chef has, your task is to determine the smallest positive integer that cannot be represented with those candles.

Input:

Input will begin with an integer T?100, the number of test cases. Each test case consists of a single line with exactly 10 integers, each between 0 and 8, inclusive. The first integer of each test case represents the number of '0' candles the chef has, the second integer represents the number of '1' candles the chef has, and so on.

Output:

For each test case, output on a single line the smallest positive integer that cannot be expressed with the given candles.

Sample input:

3
2 1 1 4 0 6 3 2 2 2
0 1 1 1 1 1 1 1 1 1
2 2 1 2 1 1 3 1 1 1
 

Sample output:

4
10
22
 

Author: pieguy
Date Added: 26-09-2010
Time Limit: 2 sec
Source Limit: 50000 Bytes
Languages: ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC


  • Submit

Comments

  • Login or Register to post a comment.

i am getting tle for this

codejack @ 16 Oct 2010 12:32 PM

i am getting tle for this question.. i dnt see how that is possibe??.. admin is my program not giving answer for certain cases or sumthing??

please explain some more

iit2009088 @ 23 Oct 2010 09:50 PM

please explain some more things

An interesting modification

milanpopovic @ 1 Nov 2010 09:48 PM

An interesting modification to this problem will be to find how many of each candle type is needed to "candle write" all birthdays to let's say 150 years old.

please provide some more

Gaurav Jain @ 15 Dec 2010 12:22 AM

please provide some more cases and some special cases.. my program works fine for the above inputs and also for some of my own inputs.. i can't figure out why i am getting wrong answer..

Admin ignore my previous

Gaurav Jain @ 16 Dec 2010 11:04 AM

Admin ignore my previous comment I made a minor mistake!!

iI have subitted the

rahul2025 @ 17 Feb 2011 09:55 PM

iI have subitted the solution, bt it says wrong answer...

while on my system it is working absolutely fine...

@admin: wt is d problem with my solution???

I didn't get how output is

avinash_jain @ 22 Feb 2011 09:01 PM

I didn't get how output is coming

i'm getting a runtime error

jishnuunique @ 6 Mar 2011 10:57 PM

i'm getting a runtime error here,...but i can't sort it out....please help....

the input to the problem is

nikgpuec @ 23 Apr 2011 06:47 PM

the input to the problem is to be separated by spaces or not??

e.g

2 1 1 4 0 6 3 2 2 2

are these separated by spaces ?
if yes , then i m not able to understand y m i getting wrong ans..

I'm getting wrong answer and

kapilagarwal @ 20 May 2011 11:49 AM
I'm getting wrong answer and I've checked so many cases which are working fine but here, it is giving wrong answer. My soln id is 550867. Admin pls help

I'm getting wrong answer and

k.sampath kumar @ 19 Jun 2011 08:46 AM
I'm getting wrong answer and I've checked so many cases anf for given inputs which are working fine but here, it is giving wrong answer. My soln id is 576946. Admin pls help!!!

i m using the following

vioky @ 28 Jul 2011 08:57 AM
i m using the following algo: if(array has a zero) print the index, for 0 at 0th index print 10... else find the min value present in arr and its index... if the index comes out to be 0 then again traverse the array from i=1 and check if same min value is present at any other index... if it is dere, update the min value and its index and print the index (min+1) times... if still index is 0 print 10^(min+1)... anyone let me know if i m missing any case.... my sol id... http://www.codechef.com/viewsolution/608292

iI have subitted the

kul_bhushan @ 15 Aug 2011 08:28 PM
iI have subitted the solution, bt it says wrong answer... while on my system it is working absolutely fine... @admin: wt is d problem with my solution???

can sum1 plz tell me the

leo90 @ 4 Sep 2011 09:55 PM
can sum1 plz tell me the problem wid my code under id: 646808... submitted on 4th september 2011. the code is has comments at appropriate places. so there wud be no problem understanding it..... assistance wud be highly appreciated.

can anybdy tl me wat exactly

lovika @ 28 Sep 2011 02:48 AM
can anybdy tl me wat exactly we hv to do in ths..?

Admins, I tried submitting

dipankar_patro @ 16 Oct 2011 08:05 PM
Admins, I tried submitting the answer both in python and C++, but it is giving wrong answer. Checked other's successful submissions and found their algo to be same as mine. Could you guys run a check?

It should be "between 0 and 9

richi18007 @ 12 Jan 2012 05:07 PM
It should be "between 0 and 9 inclusive" in the input specification paragraph

please explain.... i am not

parul_kohli @ 7 Feb 2012 07:09 PM
please explain.... i am not getting this.

The boundary conditions in

srinihoner @ 10 Mar 2012 10:50 PM
The boundary conditions in the example thwart the proper run of the program... How could you Codechef ?

I think there's a mistake in

pera93 @ 22 Apr 2012 07:15 PM
I think there's a mistake in task description. It says: "Each test case consists of a single line with exactly 10 integers, each between 0 and 8, inclusive." Shouldn't it be between 0 and 9? Otherwise it would have 9 integers in each line, not 10.

@admin.... plzzz help me..i m

mayur_taunk @ 14 May 2012 12:02 PM
@admin.... plzzz help me..i m getting wrong ans every time...i have tried it in my machine and it works from every test case..plz help me

yes it should be between 0

jonty7 @ 16 May 2012 05:33 PM
yes it should be between 0 and 9 inclusive....

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold

HELP

Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:

 

  • Accepted Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark.
  • Time Limit Exceeded Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach.
  • Wrong Answer Your program compiled and ran succesfully but the output did not match the expected output.
  • Runtime Error Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section.
  • Compilation Error Your code was unable to compile. When you see this icon, click on it for more information.
  • If you are still having problems, see a sample solution here.

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 algorithms, computer programming and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and another smaller programming challenge in the middle of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm 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 programming contest judge accepts solutions in over 35+ programming languages. Preparing for coding contests were 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 challenges 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 coding contest and the shorter format Cook-off coding contest. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to Rs.20,000 and $700lots more CodeChef goodies up for grabs.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be a part of CodeChef's Forums and interact with all our programmers - they love helping out other programmers and sharing their ideas. Have discussions around binary search, array size, branch-and-bound, Dijkstra's algorithm, Encryption algorithm and more by visiting the CodeChef Forums and Wiki section.

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. You can also host a coding contest for your institute on CodeChef, organize an algorithm event and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.

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