Created
June 30, 2017 14:20
-
-
Save AvocadosConstant/21ef955881d00c669b7328f0c77234ce to your computer and use it in GitHub Desktop.
Solution to http://100.70.19.162:8000/contest/32/7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
""" | |
Solution to http://100.70.19.162:8000/contest/32/7 | |
""" | |
stack = list(map(int, sys.stdin.read().splitlines())) | |
del stack[0] | |
stack = [(i, True) for i in stack] | |
popped = [] | |
while stack: | |
val = stack[0][0] | |
if val >= len(stack) or not stack[val][1]: | |
popped.append(stack.pop(0)[0]) | |
else: | |
stack[0], stack[val] = stack[val], (val, False) | |
print(','.join(map(str, popped))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment