結果
問題 | No.490 yukiソート |
ユーザー |
|
提出日時 | 2017-03-31 04:17:10 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 574 bytes |
コンパイル時間 | 443 ms |
コンパイル使用メモリ | 62,888 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-07 03:38:19 |
合計ジャッジ時間 | 1,731 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 34 |
ソースコード
#include <iostream>#include <vector>#include <algorithm>void swap(int &a, int&b) {int temp = a;a = b;b = temp;}int main() {int n = 0;std::cin >> n;std::vector<int> a;for (int i = 0; i < n; i++) {int temp;std::cin >> temp;a.push_back(temp);}for (int i = 1; i < 2 * n - 3; i++) {int p = 0;int q = i;while (p < q) {if (q <= n - 1 && a[p] > a[q]) swap(a[p], a[q]);p++;q--;}}for (auto itr = a.begin(); itr != a.end(); itr++) {std::cout << *itr << ' ';}std::cout << std::endl;}