Advertisement
Guest User

Pociągi

a guest
Feb 27th, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None | 0 0
  1. def konw(m):
  2.     h=0
  3.     minu=m
  4.     while minu>=60:
  5.         minu-=60
  6.         h+=1
  7.     return h,minu
  8.    
  9.  
  10. nazwy={}
  11. minuty={}
  12. godziny={}
  13. x,y = input().split()
  14. x=int(x)
  15. y=int(y)
  16. for i in range(x):
  17.     s = input()
  18.     s = list(s)
  19.     s.pop(-1)
  20.     s = ''.join(s)
  21.     s = s.split()
  22.     nazw=s[3]
  23.     s = s[-4] + " " + s[-3] + " " + s[-1]
  24.     minuty[s]=0
  25.     godziny[s]=0
  26.     nazwy[nazw]=s
  27. for i in range (y):
  28.     x = input().split()
  29.     h = x[3]
  30.     h = h.split(":")
  31.     god=int(h[0])
  32.     minu=int(h[1])
  33.     op=int(x[-2])
  34.     poc = x[8] + " " + x[9] + " " + x[11]
  35.     czas=(god*60)+minu+op
  36.     if poc in godziny:
  37.         if godziny[poc]==0:
  38.             godziny[poc]=czas
  39.         else:
  40.             if czas>godziny[poc]:
  41.                 godziny[poc]=czas
  42.            
  43.            
  44.    
  45. for i in sorted (nazwy.keys()) :
  46.     godz,minut=konw(godziny[nazwy[i]])
  47.     godz=str(godz)
  48.     minut=str(minut)
  49.     if len(godz)==1:
  50.         godz="0"+godz
  51.     if len(minut)==1:
  52.         minut="0"+minut
  53.     print(godz+":"+minut)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement