美团8.22笔试(5题) 投票
补个第五题AC的 python 版本,A 、B哪个队伍人少,就优先把能量高的人安排进去
x, y = [int(_) for _ in sys.stdin.readline().strip().split()] power = [int(_) for _ in sys.stdin.readline().strip().split()] power = sorted([ (e,i) for i, e in enumerate(power)], key = lambda x: [-x[0], x[1]]) if x == y: print("A" * x + "B" * y) else: res = [] if x > y: res = list("B" * (x + y)) for e, i in power[y:]: res[i] = "A" else: res = list("A" * (x + y)) for e, i in power[x:]: res[i] = "B" print("".join(res))