import sys args = [] index = 0 temp = [] for line in sys.stdin: a = line.split("\n")[0] if index == 0: temp.append(int(a)) elif index == 1: temp.append([int(_) for _ in a.split(" ")]) elif index == 2: index = 0 temp.append(int(a)) args.append(temp) temp = [] continue index += 1 for arg in args: #print(arg[1],len(arg[1])-arg[2]) print(arg[1][len(arg[1])-arg[2]])
这个可以用数组来偷懒,如果要用链表,搞个双向的也行