結果
問題 | No.14 最小公倍数ソート |
ユーザー |
|
提出日時 | 2022-07-24 08:51:08 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 412 bytes |
コンパイル時間 | 526 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-07-06 01:19:12 |
合計ジャッジ時間 | 7,026 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 2 WA * 2 TLE * 1 -- * 15 |
ソースコード
import math n = int(input()) a = list(map(int, input().split())) ans = [] ans.append(a.pop(0)) for i in range(n - 1): base = ans[-1] lc = math.inf; min_i = -1 idx = -1 for j in range(n - len(ans)): if lc >= math.lcm(base, a[j]): lc = math.lcm(base, a[j]) min_i = a[j] idx = j ans.append(min_i) a.pop(idx) print(' '.join(map(str, ans)))