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


Need help in Codeforces Carrot Cakes

I am having trouble in coming up with a solution for Carrot Cakes. The editorials are provided but I can't understand how do we arrive at such a formula..

asked 24 Jun '18, 16:11

montycs's gravatar image

accept rate: 0%

edited 24 Jun '18, 18:09

let's say we don't build second one.

Then it's just simple to calculate TimeWithoutBuild using formula :

TimeWithoutBuild = ceil(n/k)* t

Now let's build the second and calculate the TimeWithBuild:

as it take d unit time to build, we first add d to TimeWithBuild now we might have already baked some cakes while building the second one. So we need to subtract that cakes from n, so our remaining cakes will be n-(d/t)*k let's say this is n_rem Now our speed of baking is doubled So

TimeWithBuild = d + ceil(n_rem/(2*k)) * t

Now you will be good to code it yourself but nevertheless here is my solution.... Good Luck :p

View Content

answered 24 Jun '18, 20:46

meet2mky's gravatar image

accept rate: 28%

Thanks for replying.. Can explain the last part i.e n-(d/t)*k in detail ? I don't get it..

(25 Jun '18, 15:49) montycs0★
toggle preview

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 24 Jun '18, 16:11

question was seen: 119 times

last updated: 25 Jun '18, 16:07