結果

問題 No.14 最小公倍数ソート
コンテスト
ユーザー gew1fw
提出日時 2025-06-12 21:00:40
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 319 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 229 ms
コンパイル使用メモリ 95,976 KB
実行使用メモリ 307,968 KB
最終ジャッジ日時 2026-07-12 02:10:08
合計ジャッジ時間 7,826 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 4 TLE * 1 -- * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import math

n = int(input())
a = list(map(int, input().split()))

for i in range(n):
    ai = a[i]
    sub = a[i+1:]
    # Sort sub based on LCM with ai and then by the element value
    sub_sorted = sorted(sub, key=lambda x: ((ai * x) // math.gcd(ai, x), x))
    a = a[:i+1] + sub_sorted

print(' '.join(map(str, a)))
0