結果
| 問題 | No.14 最小公倍数ソート |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-16 04:02:14 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
TLE
不安定
|
| 実行時間 | - |
| コード長 | 742 bytes |
| 記録 | |
| コンパイル時間 | 1,871 ms |
| コンパイル使用メモリ | 189,232 KB |
| 実行使用メモリ | 395,264 KB |
| 最終ジャッジ日時 | 2026-10-16 04:04:24 |
| 合計ジャッジ時間 | 111,872 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 TLE * 10 |
ソースコード
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
int main() {
using namespace std;
int n;
cin >> n;
vector<int> a(n);
for (auto &e : a) { cin >> e; }
constexpr int m = 10010;
vector LCM(m, vector<int>(m));
for (int i = 1; i < m; i++) {
for (int j = 1; j < m; j++) {
LCM[i][j] = lcm(i, j);
}
}
for (int i = 0; i < n; i++) {
sort(a.begin() + i + 1, a.end(), [&](const int x, const int y) {
if (LCM[x][a[i]] != LCM[y][a[i]]) {
return LCM[x][a[i]] < LCM[y][a[i]];
} else {
return x < y;
}
});
}
for (auto e : a) { cout << e << " "; }
cout << endl;
}