結果

問題 No.490 yukiソート
ユーザー YamaKasaYamaKasa
提出日時 2018-05-25 01:44:36
言語 Java
(openjdk 23)
結果
AC  
実行時間 314 ms / 2,000 ms
コード長 590 bytes
コンパイル時間 2,240 ms
コンパイル使用メモリ 76,312 KB
実行使用メモリ 44,764 KB
最終ジャッジ日時 2024-06-28 17:49:55
合計ジャッジ時間 10,623 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int []a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		scan.close();
		for(int i = 1; i < 2 * n - 3; i++) {
			for(int p = 0; p < n - 1; p++) {
				int q = i - p;
				if(q > p && q <= n - 1) {
					if(a[p] > a[q]) {
						int t = a[p];
						a[p] = a[q];
						a[q] = t;
					}
				}
			}
		}
		for(int i = 0; i < n - 1; i++) {
			System.out.print(a[i] + " ");
		}
		System.out.println(a[n - 1]);

	}
}
0