結果
| 問題 | No.14 最小公倍数ソート |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-16 04:13:15 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 1,647 ms / 5,000 ms |
| + 252µs | |
| コード長 | 622 bytes |
| 記録 | |
| コンパイル時間 | 1,303 ms |
| コンパイル使用メモリ | 180,152 KB |
| 実行使用メモリ | 9,924 KB |
| 最終ジャッジ日時 | 2026-10-16 04:13:38 |
| 合計ジャッジ時間 | 22,213 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
#include <algorithm>
#include <iostream>
#include <numeric>
#include <utility>
#include <vector>
int main() {
using namespace std;
int n;
cin >> n;
vector<int> a(n);
for (auto &e : a) { cin >> e; }
for (int i = 0; i < n - 1; i++) {
int pos = i, min_lcm = 1e9;
for (int j = i + 1; j < n; j++) {
int lj = lcm(a[i], a[j]);
if (lj < min_lcm || (lj == min_lcm && a[j] < a[pos])) {
pos = j;
min_lcm = lj;
}
}
swap(a[i + 1], a[pos]);
}
for (auto e : a) { cout << e << " "; }
cout << endl;
}