結果
| 問題 | No.14 最小公倍数ソート |
| コンテスト | |
| ユーザー |
y_mazun
|
| 提出日時 | 2015-04-24 00:42:41 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 1,957 ms / 5,000 ms |
| コード長 | 625 bytes |
| 記録 | |
| コンパイル時間 | 332 ms |
| コンパイル使用メモリ | 68,600 KB |
| 実行使用メモリ | 6,144 KB |
| 最終ジャッジ日時 | 2026-03-26 07:38:13 |
| 合計ジャッジ時間 | 22,574 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
#include <algorithm>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#include <queue>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }
#include <set>
using namespace std;
int main(){
const int n = getInt();
vector<int> a(n);
REP(i,n) a[i] = getInt();
REP(i,n-1){
const int aa = a[i];
pair<int, pair<int, int> > t = make_pair(1000000000, make_pair(0, 0));
for(int j = i + 1; j < n; j++){
t = min(t, make_pair(aa * a[j] / __gcd(aa, a[j]), make_pair(a[j], j)));
}
swap(a[i + 1], a[t.second.second]);
}
REP(i,n) printf("%d ", a[i]);
puts("");
return 0;
}
y_mazun