We can avoid an iterative algorithm, and simply solve the following equation:
F=ceil(N-(K-1)/2^floor(log2(K)))-1 Where F is the number of free stalls surrounding us once we have taken our stall. Then, the output is simply ceil(F/2) and floor(F/2). What do you think of it? PS: my javascript implementation: https://code.google.com/codejam/contest/3264486/scoreboard/do/?cmd=GetSourceCode&problem=5654742835396608&iosetid=0&username=cdms&csrfmiddlewaretoken=OTM3NDQ5NzE1ZDQzYzE2MTk0OTgwOWRhZWFjMjIyYWV8MTA3NzY0MjYxODUzNTM5MjQzOTcxfDE0OTE5NzkzMjQ0OTc1NDA%3D -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/ded037ec-1dfe-43a7-a4cd-2bdf76f3bd34%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
