fork download
  1. from sys import stdout
  2. import os
  3. import io
  4.  
  5. input = io.BytesIO(os.read(0, \
  6. os.fstat(0).st_size)).readline
  7.  
  8. n: int = int(input())
  9.  
  10. while n:
  11. n -= 1
  12.  
  13. line = input().decode()
  14.  
  15. distance, time = line.strip().split()
  16. meters = float(distance)
  17. h, m, s = [float(i) for i in time.split(":")]
  18.  
  19. seconds = s
  20. seconds += m * 60.0
  21. seconds += h * 60.0 * 60.0
  22.  
  23. kilometers = meters/1000
  24. result = seconds/kilometers
  25. diff = float(result - round(result))
  26.  
  27. if diff >= 0.5:
  28. result = round(result) + 1
  29. else:
  30. result = round(result)
  31.  
  32. m, s = divmod(result, 60)
  33.  
  34. stdout.write(f"{m}:{s:02d}\n")
Success #stdin #stdout 0.02s 9332KB
stdin
3
1200 00:06:09
6000 00:30:02
10000 00:55:05
stdout
5:08
5:00
5:31