You are on page 1of 2

n = int(input())

start,end = input().split(' ')


l=[]
for i in range(n):
l.append(input())
def getseconds(date):
h,m,s = list(map(int,date.split(':')))
return h*60*60 + m*60 + s
start = getseconds(start)
end = getseconds(end)
duration = end-start+1
r = [0 for i in range(duration+1)]
time_attended={}
for item in l:
temp = list(item.split(' '))
time_attended[temp[0]] = []
i=2
while(i<len(temp)):
s,e = getseconds(temp[i]), getseconds(temp[i+1])
i+= 2
s,e=s-start, e-start
r[s]+=1
r[e]-=1
time_attended[temp[0]].append([s,e-1])
time_stamps_of_min = set()
new = []
new.append(r[0])
for i in range(1,len(r)-1):
new.append(r[i]+new[-1])
new.pop()
mini = min(new)
for i in range(len(new)):
if(new[i]==mini):
time_stamps_of_min.add(i)
set_SID1 = set()
for item in time_attended['1']:
set_SID1 = set_SID1.union(set(range(item[0],item[1]+1)))
set_SID1= set_SID1.intersection(time_stamps_of_min)
import math
if(len(set_SID1)==0):
print(0)
else:
a,b = len(set_SID1), len(time_stamps_of_min)
c = math.gcd(a,b)
print(a//c,'/',b//c,sep='')

You might also like