結果

問題 No.365 ジェンガソート
ユーザー shinwisteriashinwisteria
提出日時 2017-04-01 11:43:33
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 594 bytes
コンパイル時間 4,477 ms
コンパイル使用メモリ 72,796 KB
実行使用メモリ 56,852 KB
最終ジャッジ日時 2023-09-22 01:57:41
合計ジャッジ時間 10,003 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
44,668 KB
testcase_01 AC 119 ms
39,696 KB
testcase_02 AC 121 ms
39,372 KB
testcase_03 AC 121 ms
39,360 KB
testcase_04 AC 119 ms
39,232 KB
testcase_05 AC 121 ms
39,388 KB
testcase_06 AC 124 ms
39,648 KB
testcase_07 AC 118 ms
39,548 KB
testcase_08 AC 118 ms
39,808 KB
testcase_09 AC 119 ms
39,704 KB
testcase_10 AC 121 ms
39,096 KB
testcase_11 AC 121 ms
39,336 KB
testcase_12 AC 132 ms
39,672 KB
testcase_13 AC 126 ms
39,236 KB
testcase_14 AC 118 ms
39,320 KB
testcase_15 AC 128 ms
39,452 KB
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 #

import java.util.ArrayList;
import java.util.Scanner;
public class Jengasort {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 0;i < N;i++){
			list.add(s.nextInt());
		}
		s.close();
		int count = 0;
		for(int i = N;i > 1;i--){
			if(list.indexOf(i) < list.indexOf(i-1)){
				count++;
				list.remove(list.indexOf(i-1));
				list.add(0, i-1);
				//System.out.println(list);
			}
		}
		System.out.println(count);

	}

}
0