結果

問題 No.14 最小公倍数ソート
ユーザー szkhts
提出日時 2022-07-24 08:48:22
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 417 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 18,848 KB
最終ジャッジ日時 2024-07-06 01:07:19
合計ジャッジ時間 7,420 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 4 TLE * 1 -- * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

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]
    print("base:", base)
    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(ans)
0