結果
| 問題 | No.490 yukiソート |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-03-07 03:39:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 559 bytes |
| コンパイル時間 | 635 ms |
| コンパイル使用メモリ | 64,480 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-22 13:52:03 |
| 合計ジャッジ時間 | 3,176 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 26 RE * 8 |
ソースコード
#include <iostream>
void sort(int n, int* a) {
if (n <= 2) return;
for (int i = 1; i < 2 * n - 3; ++i) {
for (int p = 0; p <= n - 1; ++p) {
int q = i - p;
if (a[p] > a[q] && q <= n - 1 && p < q) {
int tmp = a[p];
a[p] = a[q];
a[q] = tmp;
}
}
}
}
int main () {
std::cin.tie(0);
std::ios::sync_with_stdio(false);
int n;
std::cin >> n;
int a[n];
for(int i = 0; i < n; ++i) {
std::cin >> a[i];
}
sort(n, a);
for(int i = 0; i < n; ++i) {
if (i) std::cout << " ";
std::cout << a[i];
}
std::cout << std::endl;
}