|
|
вернуться в форумpython-solvable ? Послано PSV 3 июл 2013 21:26 request for any optimizations possible for python solution: not it get TLE #42 import sys #sys.stdin = open("smalltest.txt") #sys.stdin = open("input.txt") top = 0 stack = [0] * 2000020 input = sys.stdin.read().split() operations = int(input[0]) ans = "" for i in xrange(operations) : op = int(input[i+1]) if op > 0 : stack[top] = op top += 1 elif op < 0 : top -= 1 ans += str(stack[top]) + "\n" else : if operations - i > top : l = max( 0, top - operations + i ) cnt = top - l stack[top:top+cnt] = stack[l:top] top += cnt sys.stdout.write( ans ) |
|
|