#K43222. Largest Time From Digits

    ID: 27262 Type: Default 1000ms 256MiB

Largest Time From Digits

Largest Time From Digits

You are given four digits. Your task is to arrange these digits to form the largest possible valid time in 24-hour format (HH:MM). If no valid time can be formed, output an empty string.

A valid time must satisfy the following conditions:

  • The hour, denoted as \(HH\), must be between 00 and 23 inclusive.
  • The minute, denoted as \(MM\), must be between 00 and 59 inclusive.

For example, given the digits 1 2 3 4, one possible arrangement is 23:41, which is the largest valid time that can be obtained from these digits.

If there is no valid time, output an empty string.

inputFormat

The input consists of a single line containing four space-separated digits.

Example: 1 2 3 4

outputFormat

Output a single line containing the largest valid time in 24-hour format (HH:MM). If no valid time can be formed, output an empty string.

## sample
1 2 3 4
23:41