#K10366. Highest Version Finder
Highest Version Finder
Highest Version Finder
You are given a list of version strings in the format MAJOR.MINOR.PATCH
. Each version consists of three non-negative integers separated by a dot (.
). Your task is to find and output the highest version string by comparing the corresponding major, minor, and patch numbers in that order.
For example, given the version strings "1.0.0", "2.1.0", "2.0.1", "1.3.4", and "2.1.1", the highest version is "2.1.1" because:
- Comparing MAJOR numbers: 1 vs 2 means any version beginning with 2 is greater.
- For versions with the same MAJOR number, the MINOR number is compared.
- If both MAJOR and MINOR numbers are equal, the PATCH number is compared.
Formally, if a version can be written as \(v = a.b.c\), then for two versions \(v_1 = a_1.b_1.c_1\) and \(v_2 = a_2.b_2.c_2\), \(v_1 > v_2\) if and only if
\[ (a_1 > a_2) \quad \text{or} \quad (a_1 = a_2 \text{ and } b_1 > b_2) \quad \text{or} \quad (a_1 = a_2 \text{ and } b_1 = b_2 \text{ and } c_1 > c_2). \]inputFormat
The input is read from standard input and has the following format:
- The first line contains an integer \(n\) representing the number of version strings.
- The next \(n\) lines each contain a version string in the format
MAJOR.MINOR.PATCH
.
outputFormat
Output the highest version string to standard output.
## sample5
1.0.0
2.1.0
2.0.1
1.3.4
2.1.1
2.1.1