fork download
  1. def parse(inFile):
  2. engines = [inFile.readline() for i in xrange(inFile.getInt())]
  3. return (len(engines),[engines.index(inFile.readline()) for i in xrange(inFile.getInt())])
  4.  
  5. def solve((N,requests)):
  6. numSwitches = 0
  7. numUsed = 0
  8. requested = [False] * N
  9. for req in requests:
  10. if not requested[req]:
  11. if (numUsed == N-1):
  12. numSwitches += 1
  13. numUsed = 0
  14. requested = [False] * N
  15. numUsed += 1
  16. requested[req] = True
  17. return numSwitches
  18.  
  19. if __name__ == "__main__":
  20. from GCJ import GCJ
  21. GCJ(parse, solve, "/Users/lpebody/gcj/2008_q/", "a").run()
  22.  
  23.  
  24.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty