Problem:


Problem A: It's our delight!!

You are a student of University of Aizu.
And you work part-time at a restaurant.

Staffs of the restaurant are well trained to be delighted to provide more delicious products faster.

The speed providing products particularly depends on skill of the staff.
So, the manager of the restaurant want to know how long it takes to provide products.

Though some restaurants employ a system which calculates how long it takes to provide products automatically,
the restaurant where you work employs a system which calculates it manually.

You, a student of University of Aizu, want to write a program to calculate it, and you hope that your program makes the task easier.
You are given the checks in a day.
If the length of time it takes to provide the products of a check is shorter than or equal to 8 minutes, it is "ok" check.
Write a program to output the ratio of "ok" checks to the total in percentage.

Input

The input consists of multiple datasets.
The last dataset is followed by a line containing a single zero.
You don't have to process this data.
The first line of each dataset contains a single integer n.

n (0 <  n  ≤ 100) is the number of checks.
Each of following  n  lines gives the details of a check in the following format.

hh:mm MM

hh:mm is the clock time to print the check.
MM is minute of the clock time to provide products.
The clock time is expressed according to the 24 hour clock.

For example, "eleven one PM" is expressed by "23:01".

You can assume that the all of products are provided within fifteen minutes.
The restaurant is open from AM 11:00 to AM 02:00.
After AM 02:00, no check is printed.
Also at AM 02:00, no check is printed.

Output

Your program has to print in the following format for each dataset.

lunch L
dinner D
midnight M

 L  is ratio of "ok" check printed to the total in lunch time.
 D  is ratio of "ok" check printed to the total in  dinner time.
 M  is ratio of "ok" check printed to the total in midnight time.
You can truncate digits number after the decimal point of the ratio on the percentage. Lunch, dinner, and midnight times are defined as follows:

Lunch time is 11:00 ~ 14:59.
Dinner time is 18:00 ~ 20:59.
Midnight time is 21:00 ~ 01:59.

If a check is not printed in the three range of time, you don't have to process it.
If no check is in the range of time, you should print "no guest".

Sample input

5
12:57 59
20:12 15
12:19 21
18:52 03
16:09 14
0

Sample output

lunch 100
dinner 50
midnight no guest

Hint

If you want to read three integers in the following format,

integer:integer(space)integer

you can read them by scanf("%d%*c%d%d",&a, &b, &c); in C.

The University of Aizu Programming Contest 2011

Problemsetter: Tetsuya Shiota

-->

Sample input:
5
12:57 59
20:12 15
12:19 21
18:52 03
16:09 14
0


Sample output:
lunch 100
dinner 50
midnight no guest

Submission status: Wrong Answer

Solution code:
import datetime

# [OK, OUT]
lunch    = [0, 0]
dinner   = [0, 0]
midnight = [0, 0]

lunchStart  = datetime.time(11, 0)
lunchEnd    = datetime.time(14, 59)
dinnerStart = datetime.time(18, 0)
dinnerEnd   = datetime.time(20, 59)
midStart    = datetime.time(21, 0)
midEnd      = datetime.time(1, 59)

for i in range(int(input())):
    checkTime, offerMinute = input().split(' ')
    hour, minute = map(int, checkTime.split(':'))

    # cast
    offerMinute = int(offerMinute)

    checkDatetime = datetime.time(hour, minute)

    result = offerMinute - minute if offerMinute > minute else 60 - minute + offerMinute

    ok = 0 if result <= 8 else 1

    # Lunch
    if lunchStart <= checkDatetime and checkDatetime <= lunchEnd:
        lunch[ok] += 1
        continue
    # Dinner
    if dinnerStart <= checkDatetime and checkDatetime <= dinnerEnd:
        dinner[ok] += 1
        continue
    # Midnight
    if midStart <= checkDatetime or checkDatetime <= midEnd:
        midnight[ok] += 1
        continue

zero = input()

if sum(lunch) is 0:
    print('lunch no guest')
else:
    print('lunch {0}'.format(int(lunch[0]/sum(lunch) * 100)))

if sum(dinner) is 0:
    print('dinner no guest')
else:
    print('dinner {0}'.format(int(dinner[0]/sum(dinner) * 100)))

if sum(midnight) is 0:
    print('midnight no guest')
else:
    print('midnight {0}'.format(int(midnight[0]/sum(midnight) * 100)))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python
# -*- coding: utf-8 -*-

import datetime

# [OK, OUT]
lunch    = [0, 0]
dinner   = [0, 0]
midnight = [0, 0]

lunchStart  = datetime.time(11, 0)
lunchEnd    = datetime.time(14, 59)
dinnerStart = datetime.time(18, 0)
dinnerEnd   = datetime.time(20, 59)
midStart    = datetime.time(21, 0)
midEnd      = datetime.time(1, 59)

for i in range(int(input())):
    checkTime, offerMinute = input().split(' ')
    hour, minute = map(int, checkTime.split(':'))

    # cast
    offerMinute = int(offerMinute)

    checkDatetime = datetime.time(hour, minute)

    result = offerMinute - minute if offerMinute > minute else 60 - minute + offerMinute

    ok = 0 if result <= 8 else 1

    # Lunch
    if lunchStart <= checkDatetime and checkDatetime <= lunchEnd:
        lunch[ok] += 1
        continue
    # Dinner
    if dinnerStart <= checkDatetime and checkDatetime <= dinnerEnd:
        dinner[ok] += 1
        continue
    # Midnight
    if midStart <= checkDatetime or checkDatetime <= midEnd:
        midnight[ok] += 1
        continue

zero = input()

if sum(lunch) is 0:
    print('lunch no guest')
else:
    print('lunch {0}'.format(int(lunch[0]/sum(lunch) * 100)))

if sum(dinner) is 0:
    print('dinner no guest')
else:
    print('dinner {0}'.format(int(dinner[0]/sum(dinner) * 100)))

if sum(midnight) is 0:
    print('midnight no guest')
else:
    print('midnight {0}'.format(int(midnight[0]/sum(midnight) * 100)))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python
# -*- coding: utf-8 -*-

import datetime

# [OK, OUT]
lunch    = [0, 0]
dinner   = [0, 0]
midnight = [0, 0]

lunchStart  = datetime.time(11, 0)
lunchEnd    = datetime.time(14, 59)
dinnerStart = datetime.time(18, 0)
dinnerEnd   = datetime.time(20, 59)
midStart    = datetime.time(21, 0)
midEnd      = datetime.time(1, 59)

for i in range(int(input())):
    checkTime, offerMinute = input().split(' ')
    hour, minute = map(int, checkTime.split(':'))

    # cast
    offerMinute = int(offerMinute)

    checkDatetime = datetime.time(hour, minute)

    result = offerMinute - minute if offerMinute > minute else 60 - minute + offerMinute

    ok = 0 if result <= 8 else 1

    # Lunch
    if lunchStart <= checkDatetime and checkDatetime <= lunchEnd:
        lunch[ok] += 1
        continue
    # Dinner
    if dinnerStart <= checkDatetime and checkDatetime <= dinnerEnd:
        dinner[ok] += 1
        continue
    # Midnight
    if midStart <= checkDatetime or checkDatetime <= midEnd:
        midnight[ok] += 1
        continue

if sum(lunch) is 0:
    print('lunch no guest')
else:
    print('lunch {0}'.format(int(lunch[0]/sum(lunch) * 100)))

if sum(dinner) is 0:
    print('dinner no guest')
else:
    print('dinner {0}'.format(int(dinner[0]/sum(dinner) * 100)))

if sum(midnight) is 0:
    print('midnight no guest')
else:
    print('midnight {0}'.format(int(midnight[0]/sum(midnight) * 100)))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python
# -*- coding: utf-8 -*-

def check(target, isOk):
    if isOk:
        target[0] += 1
    else:
        target[1] += 1
    target[2] += 1

# [OK, OUT, SUM]
lunch    = [0, 0, 0]
dinner   = [0, 0, 0]
midnight = [0, 0, 0]

n = input()

for i in range(int(n)):
    stdin = input()

    if stdin is '0':
        break

    checkTime, offerMinute = stdin.split(' ')
    hour, minute = map(int, checkTime.split(':'))

    # cast
    offerMinute = int(offerMinute)

    diff = offerMinute - minute if offerMinute > minute else 60 - minute + offerMinute
    ok   = diff <= 8

    # Lunch
    if 11 <= hour and hour <= 14:
        check(lunch, ok)
        continue
    # Dinner
    if 18 <= hour and hour <= 20:
        check(dinner, ok)
        continue
    # Midnight
    if 21 <= hour or hour <= 1:
        check(midnight, ok)
        continue

if sum(lunch) is 0:
    print('lunch no guest')
else:
    print('lunch {0}'.format(int(lunch[0]/lunch[2] * 100)))

if sum(dinner) is 0:
    print('dinner no guest')
else:
    print('dinner {0}'.format(int(dinner[0]/dinner[2] * 100)))

if sum(midnight) is 0:
    print('midnight no guest')
else:
    print('midnight {0}'.format(int(midnight[0]/midnight[2] * 100)))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python
# -*- coding: utf-8 -*-

def check(target, isOk):
    if isOk:
        target[0] += 1
    else:
        target[1] += 1
    target[2] += 1

# [OK, OUT, SUM]
lunch    = [0, 0, 0]
dinner   = [0, 0, 0]
midnight = [0, 0, 0]

n = input()

for i in range(int(n)):
    stdin = input()

    if stdin is '0':
        break

    checkTime, offerMinute = stdin.split(' ')
    hour, minute = map(int, checkTime.split(':'))

    # cast
    offerMinute = int(offerMinute)

    diff = offerMinute - minute if offerMinute > minute else 60 - minute + offerMinute
    ok   = diff <= 8

    # Lunch
    if 11 <= hour and hour <= 14:
        check(lunch, ok)
        continue
    # Dinner
    if 18 <= hour and hour <= 20:
        check(dinner, ok)
        continue
    # Midnight
    if 21 <= hour or hour <= 1:
        check(midnight, ok)
        continue

if lunch[2] is 0:
    print('lunch no guest')
else:
    print('lunch {0}'.format(int(lunch[0]/lunch[2] * 100)))

if dinner[2] is 0:
    print('dinner no guest')
else:
    print('dinner {0}'.format(int(dinner[0]/dinner[2] * 100)))

if midnight[2] is 0:
    print('midnight no guest')
else:
    print('midnight {0}'.format(int(midnight[0]/midnight[2] * 100)))

Submission status: Wrong Answer

Solution code:
while 1:
    n=int(input())
    if n==0:break
    l=d=m=cl=cm=cd=0
    for i in range(n):
        t,M=input().split()
        M=int(M)
        h,m=map(int,t.split(":"))
        if m>M:M+=60
        a=M-m<=8
        if 11<=h<15:cl+=1;l+=a
        elif 18<=h<21:cd+=1;d+=a
        elif 21<=h or h< 2:cm+=1;m+=a
    print('lunch', int(l*100/cl) if cl else 'no guest')
    print('dinner', int(d*100/cd) if cd else 'no guest')
    print('midnight', int(m*100/cm) if cm else 'no guest')

Submission status: Wrong Answer

Solution code:
while 1:
    n=int(input())
    if n==0:break
    l=d=m=cl=cm=cd=0
    for i in range(n):
        t,M=input().split()
        M=int(M)
        h,m=map(int,t.split(':'))
        if m>M:M+=60
        a=M-m<=8
        if 11<=h<15:cl+=1;l+=a
        elif 18<=h<21:cd+=1;d+=a
        elif 21<=h or h< 2:cm+=1;m+=a
    print('lunch', l*100//cl if cl else 'no guest')
    print('dinner', d*100//cd if cd else 'no guest')
    print('midnight', m*100//cm if cm else 'no guest')

Submission status: Wrong Answer

Solution code:
while 1:
    n=int(input())
    if n==0:break
    l=d=m=cl=cm=cd=0
    for i in range(n):
        t,M=input().split()
        M=int(M)
        h,m=map(int,t.split(":"))
        if m>M:M+=60
        a=M-m<=8
        if 11<=h<15:cl+=1;l+=a
        elif 18<=h<21:cd+=1;d+=a
        elif 21<=h or h< 2:cm+=1;m+=a
    print('lunch', int(l/cl*100) if cl else 'no guest')
    print('dinner', int(d/cd*100) if cd else 'no guest')
    print('midnight', int(m/cm*100) if cm else 'no guest')

Submission status: Accepted

Solution code:
# AOJ 1062: It's our delight!!
# Python3 2018.6.8 bal4u

# 昼11:00-14:59, 夕18:00-20:59, 深夜21:00-01:59
tt = [[660, 899], [1080, 1259], [1260, 1559]]
ss = ["lunch", "dinner", "midnight"]

while True:
	n = int(input())
	if n == 0: break
	cnt, ok = [0]*3, [0]*3
	for i in range(n):
		hm, MM = input().split()
		hh, mm = map(int, hm.split(':'))
		MM = int(MM)
		if hh <= 2: hh += 24
		MM = MM+hh*60 if MM >= mm else MM+(hh+1)*60
		t = hh*60+mm
		for j in range(3):
			if tt[j][0] <= t and t <= tt[j][1]:
				cnt[j] += 1
				if MM-t <= 8: ok[j] += 1
	for j in range(3):
		print(ss[j]+' ', end='')
		print("no guest" if cnt[j] == 0 else ok[j]*100//cnt[j])

Submission status: Accepted

Solution code:
while 1:
    n=int(input())
    if n==0:break
    l=d=mi=cl=cm=cd=0
    for i in range(n):
        t,M=input().split()
        M=int(M)
        h,m=map(int,t.split(":"))
        if m>M:M+=60
        a=M-m<=8
        if 11<=h<15:cl+=1;l+=a
        elif 18<=h<21:cd+=1;d+=a
        elif 21<=h or h< 2:cm+=1;mi+=a
    print('lunch', l*100//cl if cl else 'no guest')
    print('dinner', d*100//cd if cd else 'no guest')
    print('midnight', mi*100//cm if cm else 'no guest')

Submission status: Accepted

Solution code:
while True:
    n=input()
    if n==0:break
    Lok=Lng=Dok=Dng=Mok=Mng=0
    for i in range(n):
        temp=raw_input().split()
        MM=int(temp[1])
        hh,mm=map(int,temp[0].split(":"))
        diff=MM-mm if MM-mm>=0 else MM-mm+60
        if 11<=hh<15:
            if diff<=8:
                Lok+=1
            else:
                Lng+=1
        elif 18<=hh<21:
            if diff<=8:
                Dok+=1
            else:
                Dng+=1
        elif 21<=hh<=23 or 0<=hh<2:
            if diff<=8:
                Mok+=1
            else:
                Mng+=1
    print "lunch",int(float(Lok)/(Lok+Lng)*100) if Lok+Lng!=0 else "no guest"
    print "dinner",int(float(Dok)/(Dok+Dng)*100) if Dok+Dng!=0 else "no guest"
    print "midnight",int(float(Mok)/(Mok+Mng)*100) if Mok+Mng!=0 else "no guest"

Submission status: Accepted

Solution code:
def addValue(ok,ng,diff):
    if diff<=8:
        ok+=1
    else:
        ng+=1
    return ok,ng

while True:
    n=input()
    if n==0:break
    Lok=Lng=Dok=Dng=Mok=Mng=0
    for i in range(n):
        temp=raw_input().split()
        MM=int(temp[1])
        hh,mm=map(int,temp[0].split(":"))
        diff=MM-mm if MM-mm>=0 else MM-mm+60
        if 11<=hh<15:
            Lok,Lng=addValue(Lok,Lng,diff)
        elif 18<=hh<21:
            Dok,Dng=addValue(Dok,Dng,diff)
        elif 21<=hh<=23 or 0<=hh<2:
            Mok,Mng=addValue(Mok,Mng,diff)
    print "lunch",int(float(Lok)/(Lok+Lng)*100) if Lok+Lng!=0 else "no guest"
    print "dinner",int(float(Dok)/(Dok+Dng)*100) if Dok+Dng!=0 else "no guest"
    print "midnight",int(float(Mok)/(Mok+Mng)*100) if Mok+Mng!=0 else "no guest"

Submission status: Accepted

Solution code:
while 1:
    N = int(input())
    if N == 0:
        break
    a = b = c = 0
    a0 = b0 = c0 = 0
    for i in range(N):
        s0, s1 = input().split()
        h, m = map(int, s0.split(":"))
        tm = 100*h + m
        m1 = int(s1)
        if m1 < m:
            m1 += 60
        if 1100 <= tm < 1500:
            if m1 - m <= 8:
                a += 1
            a0 += 1
        elif 1800 <= tm < 2100:
            if m1 - m <= 8:
                b += 1
            b0 += 1
        elif 2100 <= tm or tm < 200:
            if m1 - m <= 8:
                c += 1
            c0 += 1
    print("lunch", 100*a//a0 if a0 else "no guest")
    print("dinner", 100*b//b0 if b0 else "no guest")
    print("midnight", 100*c//c0 if c0 else "no guest")

Submission status: Accepted

Solution code:
import math
while True:
  n = int(input())
  if n == 0:
    break
  name = ("lunch", "dinner", "midnight")
  dic = {}
  clear = {}
  for s in name:
    dic[s] = 0
    clear[s] = 0
  for _ in range(n):
    start, time = input().split()
    flag = (int(time) - int(start[3:])) % 60 <= 8
    if "11:00" <= start <= "14:59":
      dic["lunch"] += 1
      if flag:
        clear["lunch"] += 1
    elif "18:00" <= start <= "20:59":
      dic["dinner"] += 1
      if flag:
        clear["dinner"] += 1
    elif "21:00" <= start <= "23:59" or "00:00" <= start <= "01:59":
      dic["midnight"] += 1
      if flag:
        clear["midnight"] += 1
  for key in ("lunch", "dinner", "midnight"):
    if dic[key]:
      print(key, math.floor(100 * clear[key] / dic[key]))
    else:
      print(key, "no guest")