結果

問題 No.490 yukiソート
ユーザー Grenache
提出日時 2017-03-10 22:26:33
言語 Java
(openjdk 23)
結果
AC  
実行時間 259 ms / 2,000 ms
コード長 934 bytes
コンパイル時間 3,553 ms
コンパイル使用メモリ 77,408 KB
実行使用メモリ 59,440 KB
最終ジャッジ日時 2024-06-24 09:57:04
合計ジャッジ時間 11,433 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder490 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		for (int i = 1; i < 2 * n - 3; i++) {
			for (int p = 0; p < i; p++) {
				int q = i - p;
				if (q <= p || q >= n) {
					continue;
				}

				if (a[p] > a[q]) {
					int tmp = a[p];
					a[p] = a[q];
					a[q] = tmp;
				}
			}
		}

		for (int i = 0; i < n; i++) {
			if (i > 0) {
				pr.print(' ');
			}
			pr.print(a[i]);
		}
		pr.println();
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0