結果

問題 No.365 ジェンガソート
ユーザー jp_stejp_ste
提出日時 2016-05-09 21:06:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 625 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 2,114 ms
コンパイル使用メモリ 74,448 KB
実行使用メモリ 49,108 KB
最終ジャッジ日時 2024-04-20 07:07:56
合計ジャッジ時間 17,853 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
41,392 KB
testcase_01 AC 125 ms
41,344 KB
testcase_02 AC 124 ms
41,588 KB
testcase_03 AC 127 ms
41,484 KB
testcase_04 AC 129 ms
41,520 KB
testcase_05 AC 129 ms
41,532 KB
testcase_06 AC 127 ms
41,468 KB
testcase_07 AC 126 ms
41,308 KB
testcase_08 AC 127 ms
41,608 KB
testcase_09 AC 127 ms
41,132 KB
testcase_10 AC 127 ms
41,636 KB
testcase_11 AC 127 ms
41,628 KB
testcase_12 AC 127 ms
41,608 KB
testcase_13 AC 132 ms
41,472 KB
testcase_14 AC 129 ms
41,364 KB
testcase_15 AC 136 ms
41,484 KB
testcase_16 AC 568 ms
48,620 KB
testcase_17 AC 606 ms
48,384 KB
testcase_18 AC 248 ms
47,068 KB
testcase_19 AC 602 ms
48,684 KB
testcase_20 AC 380 ms
47,720 KB
testcase_21 AC 352 ms
48,000 KB
testcase_22 AC 572 ms
48,684 KB
testcase_23 AC 467 ms
48,220 KB
testcase_24 AC 514 ms
48,452 KB
testcase_25 AC 330 ms
47,768 KB
testcase_26 AC 540 ms
48,324 KB
testcase_27 AC 625 ms
48,564 KB
testcase_28 AC 543 ms
49,016 KB
testcase_29 AC 623 ms
48,800 KB
testcase_30 AC 529 ms
48,280 KB
testcase_31 AC 380 ms
47,968 KB
testcase_32 AC 327 ms
47,992 KB
testcase_33 AC 565 ms
48,268 KB
testcase_34 AC 299 ms
47,608 KB
testcase_35 AC 545 ms
48,424 KB
testcase_36 AC 505 ms
48,260 KB
testcase_37 AC 506 ms
48,248 KB
testcase_38 AC 543 ms
48,432 KB
testcase_39 AC 555 ms
49,108 KB
testcase_40 AC 594 ms
48,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner scan = new Scanner(System.in)) {
            int n = scan.nextInt();
            int list[] = new int[n];
            for(int i=0; i<n; i++) {
                list[i] = scan.nextInt();
            }
            
            int max = list[0];
            int index = 0;
            for(int i=0; i<n; i++) {
                if(max < list[i]) {
                    max = list[i];
                    index = i;
                }
            }
            
            int target = max;
            int count = 0;
            for(int i=index; i>=0; i--) {
                if(list[i] == target) { 
                    count++;
                    target--;
                }
            }
            
            System.out.println(n-count);
        }
    }
}
0