結果

問題 No.490 yukiソート
ユーザー MaxMellonMaxMellon
提出日時 2017-07-02 14:53:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 755 bytes
コンパイル時間 523 ms
コンパイル使用メモリ 64,796 KB
実行使用メモリ 13,756 KB
最終ジャッジ日時 2024-04-15 12:00:41
合計ジャッジ時間 4,448 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
13,756 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 30 ms
6,944 KB
testcase_05 AC 29 ms
6,944 KB
testcase_06 AC 30 ms
6,940 KB
testcase_07 AC 29 ms
6,940 KB
testcase_08 AC 30 ms
6,944 KB
testcase_09 AC 29 ms
6,944 KB
testcase_10 AC 29 ms
6,940 KB
testcase_11 AC 29 ms
6,940 KB
testcase_12 AC 30 ms
6,940 KB
testcase_13 AC 30 ms
6,940 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;

bool my_swap(int arr[], int p1, int p2);
bool my_order(int arr[], int p1, int p2);

int main()
{
  int n = 0;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }

  for (int i = 0; i < 2 * n - 3; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < j; k++) {
        if (k > i) break;
        if (j + k != i) continue;
        (my_order(arr, j, k)) && (my_swap(arr, j, k));
      }
    }
  }

  for (int i = 0; i < n; i++) {
    cout << arr[i] << " ";
  }
  cout << endl;
}

bool my_order(int arr[], int p1, int p2) {
  return arr[p1] <= arr[p2];
}

bool my_swap(int arr[], int p1, int p2) {
  int tmp = arr[p1];
  arr[p1] = arr[p2];
  arr[p2] = tmp;
  return true;
}

0