# Codingame: The Fastest

## Goal

Your program must judge results of marathon runners and choose the best one.

The result of each runner is represented as HH:MM:SS, where HHis hours, MM is minutes and SS is seconds.

You are given N results and the smallest time is the best.

The result of each runner is represented as HH:MM:SS, where HHis hours, MM is minutes and SS is seconds.

You are given N results and the smallest time is the best.

**INPUT:**

**Line 1:**a integer number N.

**Next N lines:**8 characters, a time result.

**OUTPUT:**

The best result.

**CONSTRAINTS:**

0 < N ≤ 10

0 ≤ hours < 24

0 ≤ minutes < 60

0 ≤ seconds < 60

0 ≤ hours < 24

0 ≤ minutes < 60

0 ≤ seconds < 60

## Solution

The crucial step to solve this problem is parsing and normalizing the runners time. We can do this by splitting at the colons and reduce the given time to seconds:

function parse(s) { var t = s.split(":").map(Number); return 3600 * t[0] + 60 * t[1] + t[2]; }

This function can now be used to implement the rest of the solution to find the minimum time:

var min_s = null; var min_n = Infinity; var N = parseInt(readline()); for (var i = 0; i < N; i++) { var t = readline(); var n = parse(t); if (n < min_n) { min_s = t; min_n = n; } } print(min_s);