MAXFIT - Editorial

PROBLEM LINK:

Practice
Contest

Author: Ram Agrawal
Tester: Ram Agrawal
Editorialist: Ram Agrawal

DIFFICULTY:

CAKEWALK
Intermediate levels like SIMPLE-EASY, EASY-MEDIUM, MEDIUM-HARD are also possible.

PREREQUISITES:

Math

PROBLEM:

Yogesh has a whiteboard of dimension NxMNxM. Also, he has an unlimited number of blackboards of dimension 2x12x1. He is allowed to rotate the blackboard. He is asked to place as many as blackboards on toptop of the whiteboard to meet the following conditions:

  1. Each blackboard can completely cover the 2x1 part of the whiteboard.
  2. No two blackboards overlap.
  3. Each blackboard can only be placed completely inside the whiteboard.

Print the maximum number of blackboards that can be completely placed on top of the whiteboard.

QUICK EXPLANATION:

n*m/2.

EXPLANATION:

Answer is floor(NM0.5). Since there is N*M cells on the whiteboard and each blackboard covers exactly two of them we cannot place more for sure. Now let’s show how to place exactly this number of blackboards. If N is even, then place M rows of N/2 blackboard and cover the whole whiteboard. Else N is odd, so cover N-1 row of the whiteboard as shown above and put floor(M/2) blackboard to the last row. In the worst case (N and M are odd) one cell remains uncovered.

SOLUTIONS:

Setter's Solution
m,n=map(int,input().split())
print((n*m)//2)
Editorialist's Solution
m,n=map(int,input().split())
print((n*m)//2)