#C7889. Smallest Cube Box

    ID: 51809 Type: Default 1000ms 256MiB

Smallest Cube Box

Smallest Cube Box

You are given n items, each with an integer side length. Your task is to determine the side length of the smallest cube-shaped box that can contain all the items.

Formally, if the side lengths are \( a_1, a_2, \dots, a_n \), then the answer is \( \max\{a_1, a_2, \dots, a_n\} \) because a cube with side length \( L \) can contain any item with side length equal to or less than \( L \).

Assume that items are rigid and cannot be reoriented to change their side length. The challenge thus reduces to selecting a cube with side length equal to the maximum length among all items.

inputFormat

The input is read from standard input (stdin) and contains two lines:

  • The first line contains a single integer n representing the number of items.
  • The second line contains n space-separated integers representing the side lengths of each item.

For example:

3
2 2 3

outputFormat

Output the side length of the smallest cube-shaped box that can contain all the items to standard output (stdout).

For example, for the above input, the output should be:

3
## sample
3
2 2 3
3

</p>