結果

問題 No.365 ジェンガソート
ユーザー SagTokiSagToki
提出日時 2018-06-04 16:21:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 563 ms / 2,000 ms
コード長 1,415 bytes
コンパイル時間 4,178 ms
コンパイル使用メモリ 78,152 KB
実行使用メモリ 63,764 KB
最終ジャッジ日時 2023-09-12 22:11:32
合計ジャッジ時間 19,201 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,420 KB
testcase_01 AC 122 ms
56,240 KB
testcase_02 AC 121 ms
56,024 KB
testcase_03 AC 123 ms
55,976 KB
testcase_04 AC 122 ms
55,444 KB
testcase_05 AC 122 ms
56,260 KB
testcase_06 AC 122 ms
56,248 KB
testcase_07 AC 123 ms
55,688 KB
testcase_08 AC 123 ms
55,424 KB
testcase_09 AC 122 ms
56,024 KB
testcase_10 AC 122 ms
55,972 KB
testcase_11 AC 122 ms
55,884 KB
testcase_12 AC 123 ms
55,672 KB
testcase_13 AC 127 ms
55,444 KB
testcase_14 AC 123 ms
56,248 KB
testcase_15 AC 128 ms
55,992 KB
testcase_16 AC 501 ms
63,272 KB
testcase_17 AC 504 ms
61,312 KB
testcase_18 AC 240 ms
61,600 KB
testcase_19 AC 546 ms
63,764 KB
testcase_20 AC 344 ms
60,732 KB
testcase_21 AC 316 ms
60,192 KB
testcase_22 AC 482 ms
62,540 KB
testcase_23 AC 385 ms
60,636 KB
testcase_24 AC 467 ms
60,560 KB
testcase_25 AC 300 ms
60,720 KB
testcase_26 AC 447 ms
60,708 KB
testcase_27 AC 532 ms
62,672 KB
testcase_28 AC 438 ms
60,736 KB
testcase_29 AC 533 ms
62,852 KB
testcase_30 AC 463 ms
60,512 KB
testcase_31 AC 334 ms
60,508 KB
testcase_32 AC 339 ms
60,988 KB
testcase_33 AC 524 ms
62,692 KB
testcase_34 AC 273 ms
60,104 KB
testcase_35 AC 466 ms
63,140 KB
testcase_36 AC 526 ms
62,720 KB
testcase_37 AC 534 ms
62,928 KB
testcase_38 AC 533 ms
62,744 KB
testcase_39 AC 563 ms
63,412 KB
testcase_40 AC 533 ms
62,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class JengaSort {
    static Scanner scanner = new Scanner(System.in);
    public static void main(String[] args){
        int N = Input(1 , 100000);
        ArrayList<Integer> High = new ArrayList<>();
        for(int i = 0 ; i < N ; i++){
            High.add(Input(1,N));
        }
        int Result = Processing(N,High);
        System.out.println(N - Result);
        
    }
    
    public static int Input(int Min , int Max){
        int Number = scanner.nextInt();
        try{
            if(Number < Min || Number > Max){
                System.out.println(Min + "以上" + Max + "以下で入力してください");
                System.exit(0);
            }
        }catch(InputMismatchException e){
            System.out.println("数字を入力してください");
            System.exit(0);
        }catch(Exception E){
            System.out.println("予期せぬエラーです");
            System.exit(0);
        }
        return Number;
    }
    
    public static int Processing(int N , ArrayList<Integer> High){
        int Count = 0;
        int Match = N;
        for(int i = N - 1 ; i >= 0 ; i--){
            if(High.get(i) == Match){
                Count++;
                Match--;
            }
        }
        //System.out.println(Count);
        return Count;
    }
}
0