Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = int(input())
- M = 60 * 60 * 12
- cnt = [0] * M
- for i in range(n):
- h, m, s = map(int, input().split(':'))
- cnt[(h - 1) * 3600 + m * 60 + s] += 1
- times = []
- for i in range(M):
- times += [i] * cnt[i]
- for i in range(n):
- times.append(times[i] + M)
- prev_sum = 0
- for i in range(1, n):
- prev_sum += (times[i] - times[i-1]) * i
- j = n - 1
- mins = prev_sum
- for i in range(n, 2*n-1):
- prev_sum += (times[i] - times[i-1]) * (n-1) - (times[i-1] - times[i-n])
- if prev_sum < mins or prev_sum == mins and j == n - 1:
- mins = prev_sum
- j = i - n
- ans = times[j]
- print("%d:%02d:%02d" % (ans // 3600 + 1, ans % 3600 // 60, ans % 60 ))
Advertisement
Add Comment
Please, Sign In to add comment