fork download
  1. def parse(inFile):
  2. words = inFile.getWords()[1:]
  3. return [(words[2*i],int(words[2*i+1])) for i in xrange(len(words)/2)]
  4.  
  5. def solve(data):
  6. pos = {'O':1,'B':1}
  7. time = {'O':0,'B':0}
  8. other = {'O':'B','B':'O'}
  9. for datum in data:
  10. [robot, button] = datum
  11. time[robot] = time[robot] + 1 + abs(button - pos[robot])
  12. pos[robot] = button
  13. if (time[robot] <= time[other[robot]]):
  14. time[robot] = time[other[robot]] + 1
  15. return max(time.values())
  16.  
  17. if __name__ == "__main__":
  18. from GCJ import GCJ
  19. GCJ(parse, solve, "/Users/lpebody/gcj/2011_q/", "a").run()
  20.  
  21.  
  22.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty