結果

問題 No.365 ジェンガソート
ユーザー tamago324_padtamago324_pad
提出日時 2016-06-03 22:12:08
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 707 bytes
コンパイル時間 2,209 ms
コンパイル使用メモリ 75,768 KB
実行使用メモリ 41,784 KB
最終ジャッジ日時 2024-04-16 23:46:49
合計ジャッジ時間 8,497 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 138 ms
41,244 KB
testcase_02 WA -
testcase_03 AC 134 ms
41,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 136 ms
41,372 KB
testcase_11 WA -
testcase_12 AC 140 ms
41,320 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 TLE -
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 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// No.365

import java.util.Scanner;
import java.util.ArrayList;

class JengaSort{

	public static void main(String[] args){

		ArrayList<Integer> jengaList = new ArrayList<>();
		Scanner scan = new Scanner(System.in);	
		int result = 0;

		int max = scan.nextInt();

		for(int i = 0; i < max; i++){
			jengaList.add(scan.nextInt());
		}

		for(int i = max - 1; i > 0; i--){
			Integer iIndex = jengaList.indexOf(i);
			Integer nIndex = jengaList.indexOf(i + 1);

			if(iIndex > nIndex){
				// 左にもっていく
				while(iIndex > 0){
					Integer before = jengaList.set(iIndex - 1, i);
					jengaList.set(iIndex, before);
					iIndex--;

				}
			}

			result++;
		}
		System.out.println(result);
	}
}
0