タプルのやり方を完全に忘れてたので、調べつつ対応しました
まあ、中身としてはうーんnamesは必要ない気がします。。。
一応出したけど。
historiesは内包表記ができなさそうなので、普通に。タプル化して配列に入れてます。
タプル化したやつをどうやっていれるかってことでちょっと迷ったけども。
その後は、sortedしたやつをそのままプリントするだけですね。
クエリじゃない問題だと思ったのですが案の定でした。
N,K = map(int,input().split())
names = {input() for _ in range(N)}
histories = []
for i in range(K):
event,charge = input().split()
histories[i] = (int(event),charge)
for year, name in sorted(histories):
print(name)
とりあえず以上です。
すみません、間違えました。。。
これだとランタイムエラーが発生して失敗します。
N,K = map(int,input().split())
names = {input() for _ in range(N)}
#あらかじめ配列の個数分のNoneが必要
histories = [None] * K
for i in range(K):
event,charge = input().split()
histories[i] = (int(event),charge)
for year, name in sorted(histories):
print(name)