Nano alarm-clocks
면접 대비시간 제한1초메모리 제한1024 MB
12시간 문자판 위의 시각을 가진 시계 n개가 있을 때, 각 시계를 앞으로만 돌려 모두 같은 시각을 가리키게 하면서 이동 시간의 합을 최소로 만들고, 그 최솟값을 시, 분, 초로 출력한다.
문제
An old watchmaker has stopped nano alarm-clocks numbered with integers from to . Nano alarm-clocks count time in hours, and in one hour there are million minutes, each minute lasting a million seconds. In order to repair them all the watchmaker should synchronize the time on all nano alarm-clocks. In order to do this he moves clock hands a certain time forward (may be zero time). Let’s name this time shift a transfer time.
Your task is to calculate the minimal total transfer time required for all nano alarm-clocks to show the same time.
입력
The first line contains a single integer --- the number of nano alarm-clocks (). In each -th of the next lines the time , , , shown on the -th clock. Integers , and show the number of hours, minutes and seconds respectively. (, , ).
출력
Output three integers separated with spaces , and --- total minimal transfer time, where , and --- number of hours, minutes and seconds respectively (, ).