fork download
  1. def hora_min(hora, minuto):
  2. return (hora*60) + minuto
  3.  
  4. n = int(input())
  5. s = {}
  6. d = {}
  7. l = {}
  8. for i in range(n):
  9. t = str(input())
  10. t = t.split()
  11. if (int(t[1]) < 23) and (int(t[1]) > 7) and (int(t[4]) < 23) and (t[0] == t[3]):
  12. if t[0] == 'sabado':
  13. s[i] = [j for j in t]
  14. if t[0] == 'domingo':
  15. d[i] = [j for j in t]
  16. if t[0] == 'lunes':
  17. l[i] = [j for j in t]
  18.  
  19. total = 0
  20.  
  21. def personas_dia(s):
  22. if len(s) > 1:
  23. h_i = []
  24. m_i = []
  25. h_f = []
  26. m_f = []
  27.  
  28. for i in s.keys():
  29. h_i.append(s[i][1])
  30. m_i.append(s[i][2])
  31. h_f.append(s[i][4])
  32. m_f.append(s[i][5])
  33.  
  34. t = []
  35.  
  36. for i in range(len(h_i)):
  37. t.append((hora_min(int(h_i[i]), int(m_i[i])), hora_min(int(h_f[i]), int(m_f[i]))))
  38.  
  39. t.sort(key=lambda x:x[1], reverse=False)
  40.  
  41. k = 0
  42. v = [t[0]]
  43.  
  44. for i in range(1, len(t)):
  45. if t[i][0] >= v[k][1]:
  46. v.append(t[i])
  47. k = k + 1
  48.  
  49. return len(v)
  50. else:
  51. return 1
  52.  
  53. if len(s) > 0:
  54. total = total + personas_dia(s)
  55. if len(d) > 0:
  56. total = total + personas_dia(d)
  57. if len(l) > 0:
  58. total = total + personas_dia(l)
  59.  
  60. print(total)
Success #stdin #stdout 0.02s 9136KB
stdin
1
lunes 8 35 lunes 23 15
stdout
0