while True: try: count = int(input()) input_str = input().strip().split(" ") k = int(input()) if k == 0: print(0) continue print(input_str[-k]) except EOFError: break
用了数组还快点。。。
while True: try: count = int(input()) input_str = input().strip().split(" ") k = int(input()) if k == 0: print(0) continue print(input_str[-k]) except EOFError: break