結果

問題 No.490 yukiソート
ユーザー tentententen
提出日時 2020-12-07 10:26:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 247 ms / 2,000 ms
コード長 947 bytes
コンパイル時間 2,076 ms
コンパイル使用メモリ 75,108 KB
実行使用メモリ 60,484 KB
最終ジャッジ日時 2023-10-17 16:00:46
合計ジャッジ時間 9,945 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
57,524 KB
testcase_01 AC 132 ms
57,448 KB
testcase_02 AC 130 ms
57,480 KB
testcase_03 AC 132 ms
57,732 KB
testcase_04 AC 163 ms
57,936 KB
testcase_05 AC 160 ms
57,612 KB
testcase_06 AC 162 ms
57,420 KB
testcase_07 AC 160 ms
57,764 KB
testcase_08 AC 169 ms
57,680 KB
testcase_09 AC 163 ms
57,884 KB
testcase_10 AC 160 ms
57,724 KB
testcase_11 AC 163 ms
57,764 KB
testcase_12 AC 161 ms
57,896 KB
testcase_13 AC 162 ms
57,772 KB
testcase_14 AC 239 ms
60,364 KB
testcase_15 AC 240 ms
60,200 KB
testcase_16 AC 239 ms
60,212 KB
testcase_17 AC 247 ms
60,408 KB
testcase_18 AC 243 ms
60,192 KB
testcase_19 AC 237 ms
60,484 KB
testcase_20 AC 241 ms
60,072 KB
testcase_21 AC 241 ms
60,076 KB
testcase_22 AC 240 ms
60,132 KB
testcase_23 AC 239 ms
60,412 KB
testcase_24 AC 131 ms
57,604 KB
testcase_25 AC 133 ms
57,656 KB
testcase_26 AC 130 ms
57,540 KB
testcase_27 AC 131 ms
57,632 KB
testcase_28 AC 131 ms
57,764 KB
testcase_29 AC 129 ms
57,712 KB
testcase_30 AC 130 ms
57,292 KB
testcase_31 AC 131 ms
57,436 KB
testcase_32 AC 131 ms
57,608 KB
testcase_33 AC 132 ms
57,600 KB
testcase_34 AC 133 ms
57,580 KB
testcase_35 AC 132 ms
57,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        for (int i = 1; i < 2 * n - 3; i++) {
            for (int j = 0; j < n - 1 && j * 2 < i; j++) {
                int p = j;
                int q = i - j;
                if (q > n - 1) {
                    continue;
                }
                if (arr[p] > arr[q]) {
                    int tmp = arr[p];
                    arr[p] = arr[q];
                    arr[q] = tmp;
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            if (i > 0) {
                sb.append(" ");
            }
            sb.append(arr[i]);
        }
        System.out.println(sb);
    }
}
0