아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Nano alarm-clocks

면접 대비

시간 제한1초메모리 제한1024 MB

요약
12시간 문자판 위의 시각을 가진 시계 n개가 있을 때, 각 시계를 앞으로만 돌려 모두 같은 시각을 가리키게 하면서 이동 시간의 합을 최소로 만들고, 그 최솟값을 시, 분, 초로 출력한다.
난이도

보통10점 중 6점

유형
정렬, 누적 합, 수학, 그리디
정답자
아직 제출이 없습니다

문제

An old watchmaker has nn stopped nano alarm-clocks numbered with integers from 11 to nn. 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 nn --- the number of nano alarm-clocks (2≤n≤1052 \le n \le 10^5). In each ii-th of the next nn lines the time hh, mm, ss, shown on the ii-th clock. Integers hh, mm and ss show the number of hours, minutes and seconds respectively. (0≤h<120 \le h < 12, 0≤m<1060 \le m < 10^6, 0≤s<1060 \le s < 10^6).

출력

Output three integers separated with spaces hh, mm and ss --- total minimal transfer time, where hh, mm and ss --- number of hours, minutes and seconds respectively (0≤m<1060 \le m < 10^6, 0≤s<1060 \le s < 10^6).

예제2

  1. 예제 1

    입력
    2
    10 0 0
    3 0 0
    
    예상 출력
    5 0 0
    
  2. 예제 2

    입력
    3
    11 999999 999999
    0 0 0
    11 999999 999999
    
    예상 출력
    0 0 2