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

×

How to solve Bytelandian gold coin ?

question

This is my solution to the problem. Can anyone tell me what is wrong with it ?

solution

asked 01 Sep '18, 21:12

ak1010's gravatar image

1★ak1010
1
accept rate: 0%


You're not attempting to convert the coins that you get from converting the first one (and so on). In the first example below: $40 \to 20 + 13 + 10 \to (10 + 6 + 5) + 13 + 10 = 44$

Some more test cases for you:

40
50
60
400

output:

44
57
68
533
link

answered 02 Sep '18, 01:42

joffan's gravatar image

5★joffan
9488
accept rate: 13%

@joffan this is my code code

Approach i used is: if (n<12) max_value=n, else: max_value = calc_max(n/2) + calc_max(n/3) + calc_max(n/4) along with saving the entries in HashMap with each value of n

Test cases mentioned above have passed, but the problem is when I submit this code, it gives me TLE.

I ran the code in my local system, gave output of 4243218150, for input: 1000000000 in around 30 seconds.

Can you or anyone help me out here ?

link

answered 26 Oct '18, 11:34

akki0214's gravatar image

1★akki0214
11
accept rate: 0%

no worries, there was a minor issue, i was not returning from recursive call, when getting value from map, its solved now

(27 Oct '18, 12:49) akki02141★
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:

×2,559
×29
×18

question asked: 01 Sep '18, 21:12

question was seen: 217 times

last updated: 27 Oct '18, 12:49