結果
問題 | No.490 yukiソート |
ユーザー |
![]() |
提出日時 | 2017-03-12 19:00:09 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 15 ms / 2,000 ms |
コード長 | 720 bytes |
コンパイル時間 | 566 ms |
コンパイル使用メモリ | 62,016 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-30 00:32:41 |
合計ジャッジ時間 | 1,672 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 34 |
ソースコード
// ConsoleApplication49.cpp : コンソール アプリケーションのエントリ ポイントを定義します。 // //#include "stdafx.h" #include <iostream> #include <vector> #include <algorithm> using namespace std; int n; vector<int> as; void yukiSort() { for (int i = 1; i < (2 * n - 3); i++) { for (int p = 0; p <= n - 1; p++) { int q = i - p; if (p < q && q <= n - 1) { if (as[p] > as[q]) { int t = as[p]; as[p] = as[q]; as[q] = t; } } } } } int main() { cin >> n; for (int i = 0; i < n; i++) { int t; cin >> t; as.push_back(t); } yukiSort(); cout << as[0]; for (int i = 1; i < n; i++) { cout << " " << as[i]; } cout << endl; return 0; }