Hi, I came across one question from codechef.
Here, we are given P and S.
Let l, b, h be the length, breadth, height of the box.
we have these two inequalities
4(l+b+h) <= P
2
(lb+bh+hl) <= S
We have to maximise the volume which is l
b*h.
We are also given that test cases will produce optimal solution.

3
Contributors
3
Replies
6
Views
5 Years
Discussion Span

What kind of help do you want? You clearly haven't done anything yourself, so it's hard to construe "help" to mean anything except "tell me the solution and how to code it".

The solutions are given in the site.
Can any one explain the solutions.

You have two constraints and one goal. The goal is ez - maximum volume of the box.
(length x width x height)

The two constraints are:

1) The length of wire to make around the edges of the box (there are 4 horizontal edges on the bottom square of the box, 4 on the top square of the box, and 4 on the vertical edges of the box.

See this picture:

2) The surface area of the box, which must be smaller than the amount of cubic cm of paper that is given in the problem.

Study the above drawing in the link, and note especially the formula for the surface area of a box. That formula tell you when you have reached the greatest possible surface area for the given problem.

Questions:

Is it true that there is a direct correlation between a greater wire length used in making the box, and the volume of the box?

Is it true that there is a direct correlation between a greater surface area of a box, and a greater volume of the box?

You need to dig deep to solve these problems, particularly if you haven't seen them before.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.