fork(1) download
  1. def trans(time):
  2. return 60*int(time[:2])+int(time[-2:])
  3.  
  4. def parse(inFile):
  5. T = inFile.getInt()
  6. [NA,NB] = inFile.getInts()
  7. return (T,[[trans(word) for word in inFile.getWords()] for j in xrange(NA)],[[trans(word) for word in inFile.getWords()] for j in xrange(NB)])
  8.  
  9. def solve((T,ABTrains,BATrains)):
  10. Aevents = [[x[0],+1] for x in ABTrains] + [[x[1]+T,-1] for x in BATrains]
  11. Bevents = [[x[0],+1] for x in BATrains] + [[x[1]+T,-1] for x in ABTrains]
  12. Aevents.sort()
  13. Bevents.sort()
  14. Aevents = [0]+[z[1] for z in Aevents]
  15. Bevents = [0]+[z[1] for z in Bevents]
  16. for i in xrange(len(Aevents)-1):
  17. Aevents[i+1] += Aevents[i]
  18. Bevents[i+1] += Bevents[i]
  19. return "%d %d" % (max(Aevents),max(Bevents))
  20.  
  21. if __name__ == "__main__":
  22. from GCJ import GCJ
  23. GCJ(parse, solve, "/Users/lpebody/gcj/2008_q/", "b").run()
  24.  
  25.  
  26.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty