False Alarm

면접 대비

시간 제한2초메모리 제한2048 MB

요약
7시부터 9시 사이에 설정된 알람 시간들이 주어질 때, 어떤 세 알람이 10분 이내에 오도록 추가할 알람 시간의 최소 개수를 구한다.
난이도

보통10점 중 4점

유형
그리디, 정렬, 구현, 완전 탐색
정답자
아직 제출이 없습니다

문제

Faina is going to sleep, but she needs to wake up early tomorrow for a very important contest. She has already set nn alarms at different times between 7:00 and 9:00 in the morning.

However, Faina is a deep sleeper. She knows that in order to wake up, she will need to hear at least three alarms within a 10-minute timespan. In other words, for some three alarms, the difference between the first and the last alarm must be 10 minutes or less.

Faina is not sure if the current set of alarms she has satisfies this condition, and she is worried she might oversleep the contest (and make her teammates angry!). Thus, she wants to set some additional alarms. All new alarms should also be set between 7:00 and 9:00, and all alarms, including the old ones, must be set at different times.

Find the smallest number of additional alarms Faina has to set to be confident that she will wake up. In particular, if she can already be sure she'll wake up, the number of additional alarms is 00.

입력

The first line contains a single integer nn, denoting the number of alarms Faina has set (1≤n≤201 \le n \le 20).

The ii-th of the following nn lines contains the time of the ii-th alarm in the h:mm format (7≤h≤97 \le \mathtt{h} \le 9; 00≤mm≤5900 \le \mathtt{mm} \le 59; if h=9\mathtt{h} = 9, then mm=00\mathtt{mm} = 00). The alarms are given in strictly increasing order of time.

출력

Print the smallest number of additional alarms Faina has to set in order to guarantee waking up.

힌트

In the first test, three alarms at 7:56, 7:59, and 8:05 guarantee that Faina will wake up.

In the second test, any time between 8:00 and 9:00 that does not coincide with existing alarms works.

In the third test, one possible solution is to set two more alarms at 7:45 and 7:46.

예제3

  1. 예제 1

    입력
    5
    7:47
    7:56
    7:59
    8:05
    8:13
    
    예상 출력
    0
    
  2. 예제 2

    입력
    7
    8:00
    8:10
    8:20
    8:30
    8:40
    8:50
    9:00
    
    예상 출력
    1
    
  3. 예제 3

    입력
    3
    7:13
    7:41
    8:36
    
    예상 출력
    2