Official algorithmic problem description and constraints.
Little Rosie has a phone with a desktop (or launcher, as it is also called). The desktop can consist of several screens. Each screen is represented as a grid of size 5Γ3, i.e., five rows and three columns.
There are π₯ applications with an icon size of 1Γ1 cells; such an icon occupies only one cell of the screen. There are also π¦ applications with an icon size of 2Γ2 cells; such an icon occupies a square of 4 cells on the screen. Each cell of each screen can be occupied by no more than one icon.
Rosie wants to place the application icons on the minimum number of screens. Help her find the minimum number of screens needed.
Detailed video explanations, mathematical intuition, and clean C++ implementation code.