結果

問題 No.490 yukiソート
ユーザー zimphazimpha
提出日時 2017-03-29 21:14:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 206 ms / 2,000 ms
コード長 2,384 bytes
コンパイル時間 2,228 ms
コンパイル使用メモリ 74,184 KB
実行使用メモリ 56,516 KB
最終ジャッジ日時 2023-09-20 20:17:23
合計ジャッジ時間 9,367 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
56,516 KB
testcase_01 AC 113 ms
55,448 KB
testcase_02 AC 114 ms
55,724 KB
testcase_03 AC 114 ms
55,620 KB
testcase_04 AC 154 ms
55,916 KB
testcase_05 AC 156 ms
55,836 KB
testcase_06 AC 154 ms
55,940 KB
testcase_07 AC 155 ms
55,832 KB
testcase_08 AC 145 ms
55,792 KB
testcase_09 AC 142 ms
55,492 KB
testcase_10 AC 146 ms
55,764 KB
testcase_11 AC 155 ms
55,560 KB
testcase_12 AC 146 ms
55,760 KB
testcase_13 AC 144 ms
55,836 KB
testcase_14 AC 201 ms
55,980 KB
testcase_15 AC 203 ms
56,032 KB
testcase_16 AC 204 ms
55,684 KB
testcase_17 AC 203 ms
55,720 KB
testcase_18 AC 203 ms
56,032 KB
testcase_19 AC 204 ms
55,684 KB
testcase_20 AC 206 ms
55,952 KB
testcase_21 AC 202 ms
55,692 KB
testcase_22 AC 201 ms
55,724 KB
testcase_23 AC 205 ms
55,756 KB
testcase_24 AC 117 ms
55,668 KB
testcase_25 AC 116 ms
55,752 KB
testcase_26 AC 115 ms
55,860 KB
testcase_27 AC 114 ms
55,312 KB
testcase_28 AC 116 ms
55,796 KB
testcase_29 AC 114 ms
55,328 KB
testcase_30 AC 113 ms
55,856 KB
testcase_31 AC 114 ms
55,748 KB
testcase_32 AC 115 ms
55,536 KB
testcase_33 AC 112 ms
55,632 KB
testcase_34 AC 113 ms
55,648 KB
testcase_35 AC 113 ms
55,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Chiaki.Hoshinomori
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task490 solver = new Task490();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task490 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(n);
            for (int i = 1; i < (2 * n - 3); i++) {
                for (int p = 0; p <= i && p < n; p++) {
                    int q = i - p;
                    if (q <= p) break;
                    if (q < n && a[p] > a[q]) {
                        int t = a[p];
                        a[p] = a[q];
                        a[q] = t;
                    }
                }
            }
            for (int i = 0; i < n; i++) {
                out.printf("%d ", a[i]);
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] nextIntArray(int n) {
            int[] r = new int[n];
            for (int i = 0; i < n; i++) {
                r[i] = nextInt();
            }
            return r;
        }

    }
}

0