You are not logged in. Please login at www.codechef.com to post your questions!

×

Approach for Cooking Game

Please share your approach for cooking game in February cook-off.

asked 20 Feb '17, 00:11

hrushikesh_t's gravatar image

4★hrushikesh_t
534
accept rate: 0%


put arr[1] = 1 , if arr[i] = x , then put arr[i - 1] = x - 1 , arr[i - 2] = x - 2 ... till it becomes 1 , now answer is just 2 ^ (count of -1's).

link

answered 20 Feb '17, 00:23

rajat1603's gravatar image

7★rajat1603
1.0k112
accept rate: 4%

First of all for all i's(stating from i=n) such that a[i+1]>1, set a[i]=a[i+1]-1 if it is -1 or a[i+1]-1.else array is invalid. Second checked if a[i]=1or-1 if it is anything else array is invalid.set a[i]=1 now every a[i]=-1 can be changed to a[i-1]+1 or 1.(2 possibilities for every such i) so final answer is 2^x.(x=no. of i's such that a[i]=-1). if array is invalid answer is 0.

link

answered 20 Feb '17, 00:30

sunil5798's gravatar image

3★sunil5798
212
accept rate: 0%

edited 20 Feb '17, 00:32

First of all for all i's such that a[i+1]>1, set a[i]=a[i+1]-1 if it is -1 or a[i+1]-1.else array is invalid. Second checked if a[i]=1or-1 if it is anything else array is invalid.set a[i]=1 now every a[i]=-1 can be changed to a[i-1]+1 or 1.(2 possibilities for every such i) so final answer is 2^x.(x=no. of i's such that a[i]=-1). if array is invalid answer is 0.

link

answered 20 Feb '17, 00:30

sunil5798's gravatar image

3★sunil5798
212
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×61

question asked: 20 Feb '17, 00:11

question was seen: 329 times

last updated: 20 Feb '17, 00:32