結果
問題 | No.2740 Old Maid |
ユーザー |
|
提出日時 | 2024-04-21 01:19:41 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 353 ms / 2,000 ms |
コード長 | 503 bytes |
コンパイル時間 | 145 ms |
コンパイル使用メモリ | 82,836 KB |
実行使用メモリ | 119,552 KB |
最終ジャッジ日時 | 2024-10-12 23:39:53 |
合計ジャッジ時間 | 12,015 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 62 |
ソースコード
N = int(input())p = list(map(int, input().split()))prev = [-1] + list(range(N-1))next = list(range(1, N)) + [-1]sorted_args = sorted(range(N), key=lambda x: p[x])left = [True]*Nans = []for x in sorted_args:if not left[x]:continueif next[x] == -1:continuey = next[x]left[x] = Falseleft[y] = Falsepr = prev[x]n = next[y]if pr != -1:next[pr] = nif n != -1:prev[n] = prans.extend([p[x], p[y]])print(*ans)