結果
| 問題 |
No.14 最小公倍数ソート
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 16:06:22 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 445 bytes |
| コンパイル時間 | 275 ms |
| コンパイル使用メモリ | 82,736 KB |
| 実行使用メモリ | 251,760 KB |
| 最終ジャッジ日時 | 2025-06-12 16:06:33 |
| 合計ジャッジ時間 | 7,389 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 TLE * 1 -- * 15 |
ソースコード
import sys
import math
def main():
input = sys.stdin.read().split()
n = int(input[0])
a = list(map(int, input[1:n+1]))
for i in range(n-1):
current = a[i]
sub = a[i+1:]
# Sort sub based on LCM with current, then their value
sub.sort(key=lambda x: (x // math.gcd(x, current) * current, x))
a = a[:i+1] + sub
print(' '.join(map(str, a)))
if __name__ == '__main__':
main()
gew1fw