結果
| 問題 |
No.14 最小公倍数ソート
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 21:02:08 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 346 bytes |
| コンパイル時間 | 189 ms |
| コンパイル使用メモリ | 81,852 KB |
| 実行使用メモリ | 272,032 KB |
| 最終ジャッジ日時 | 2025-06-12 21:04:39 |
| 合計ジャッジ時間 | 7,254 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 TLE * 1 -- * 15 |
ソースコード
import math
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
pivot = a[i]
s = a[i+1:]
s_with_lcm = [((pivot * x) // math.gcd(pivot, x), x) for x in s]
s_sorted = sorted(s_with_lcm, key=lambda t: (t[0], t[1]))
sorted_x = [x for (lcm, x) in s_sorted]
a[i+1:] = sorted_x
print(' '.join(map(str, a)))
gew1fw