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 » Wiki » October CookOff Contest Problem Editorials

October CookOff Contest Problem Editorials

Cooling Pies (written by David Stolp aka PieGuy)

The following greedy algorithm always finds the optimum answer:

  1. Choose the lightest pie not yet on a rack
  2. If none of the remaining racks can hold this pie, stop
  3. Of all the racks that can hold this pie, place the pie on the rack with the smallest weight limit
  4. If there are no more pies, stop. Otherwise, go back to step 1

You can find the solutions below:

Problem Testers Solution.

Birthday Candles (written by David Stolp aka PieGuy)

The answer will always be either a repdigit (a number composed of repeated instances of the same digit) or a power of 10. We find the smallest power of 10 that cannot be expressed, and for each digit we find the smallest repdigit that cannot be expressed, and take the smallest of these.

 

You can find the solutions below:

Problem Testers Solution.

 

The Perfect Chocolate Candy (written by David Stolp aka PieGuy)

Each candy can be thought of as having either a surplus of chocolate, or a deficit (which may also be thought of a negative surplus) of chocolate, defined as the amount of chocolate that would need to be removed (or added) in order for a particular candy to have the perfect ratio. If all candies have a positive surplus, or all candies have a negative, then no solution exists. Otherwise we wish to find some selection of candies whose total net surplus is zero. We first note that each candy's surplus, when multiplied by desiredCaramel, will yield an integer. That is, if we denote si = Chocolatei*desiredCaramel - Carameli*desiredChocolate, then the surplus of candy i is si/desiredCaramel. Our task is to find integers pi such that sum(si*pi)=0, and not all pi are 0. Equivalently, consider a graph where nodes are labeled ...-2, -1, 0, 1, 2... and there exists a directed edge from A to B if there is some candy i for which si=B-A. Our task is to find the shortest cycle in this graph.

The shortest cycle can be found using a breadth first search, but we need to keep the size of the graph small in order to make our search effective. If M is the maximum surplus, and m is the maximum deficit (that is, the negative value furthest from 0), then we need only consider nodes in the range [m*desiredCaramel, M*desiredCaramel]. To see this, suppose we have some collection of candies whose total net surplus is 0. We can add 1 candy at a time and form partial sums in such a way that the partial sum will always be in the range [m, M] as follows: whenever the partial sum is positive, choose a candy with negative surplus, otherwise choose a candy with positive surplus.

 

You can find the solutions below:

Problem Setters Solution.
Problem Testers Solution.

 

Two Chefs (written by David Stolp aka PieGuy)

This problem can be solved using dynamic programming. We assign dishes to the ovens, one at a time, and in the order they must be completed, while memoizing:
memo[d1][d2][t] = number of minutes required to finish cooking all dishes, where

  • first chef's first d1 dishes have been assigned to an oven
  • second chef's first d2 dishes have been assigned to an oven
  • one of the ovens has just finished cooking all of the dishes assigned to it, and the other will finish cooking all of the dishes assigned to it in t minutes

From each state, the next dish we assign can be from either chef, and can go in either oven. In order to satisfy the order constraint, when we assign a dish to an oven we require it to finish cooking at the same time or after the last dish assigned to the other oven.

 

You can find the solutions below:

Problem Setters Solution.
Problem Testers Solution.

 

Product of Digits (written by David Stolp aka PieGuy)

We are given that the answer will have fewer than 700 digits (the maximum is actually 613). It suffices to find all solutions to the equation 2a3b5c7d=P(mod 1000000007), subject to a/3+b/2+c+d<700. To do this, we first make a list of all values Q such that 2a3b=Q(mod 1000000007) has a solution with a/3+b/2<700. We sort this list, so we can perform fast searches on it using binary search. Now for all possible values c and d with c+d<700 we check if 5-c7-dP is in our sorted list. If so, we've found a potential solution to the problem. Given candidate values of a, b, c, and d, we compute the answer by greedily taking as many 9's as possible, then as many 8's as possible, and so on, down to 2. Note that the digit 1 is never used, except when P itself is 1 or 0.

 

You can find the solutions below:

Problem Setters Solution.
Problem Testers Solution.

 


Comments

  • Login or Register to post a comment.

plzzz explain the concepts a

ankitsablok @ 16 Oct 2010 12:39 AM

plzzz explain the concepts a bit more these dont prove to be benficial

Please make the contest

player @ 16 Oct 2010 12:40 AM

Please make the contest problems available in the practice section

Contest problems are now

admin @ 16 Oct 2010 01:06 AM

Contest problems are now available in the practice section

Can the judges please upload

rahulakaneo @ 16 Oct 2010 01:32 AM

Can the judges please upload their solutions!

The solutions have been

admin @ 19 Oct 2010 01:08 AM

The solutions have been uploaded now. Hopefully it will help.

Also the tested for this month's contest was:Maxim Kolosovskiy

Thank you so much Admin.

rahulakaneo @ 23 Oct 2010 10:50 AM

Thank you so much Admin. These solutions are definitely going to help.

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