#C8648. Maximum Non-Overlapping Light Strings on a Grid
Maximum Non-Overlapping Light Strings on a Grid
Maximum Non-Overlapping Light Strings on a Grid
Given a grid with dimensions (L) (length) and (W) (width), you are required to compute the maximum number of non-overlapping light strings that can be installed along its borders. The lights are arranged vertically and horizontally along the grid edges such that they do not overlap. The optimal configuration yields a total count given by (L + W).
For example, if (L = 5) and (W = 3), then the maximum number is (5 + 3 = 8).
inputFormat
The input consists of two space-separated integers (L) and (W), representing the length and width of the grid respectively. It is guaranteed that (1 \leq L, W \leq 50).
outputFormat
Output a single integer which is the maximum number of non-overlapping light strings that can be placed along the grid's borders, calculated as (L + W).## sample
5 3
8