結果

問題 No.365 ジェンガソート
ユーザー tentententen
提出日時 2022-10-13 08:56:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 1,383 bytes
コンパイル時間 3,310 ms
コンパイル使用メモリ 74,380 KB
実行使用メモリ 56,220 KB
最終ジャッジ日時 2023-09-08 18:55:42
合計ジャッジ時間 10,426 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,584 KB
testcase_01 AC 43 ms
49,836 KB
testcase_02 AC 43 ms
49,384 KB
testcase_03 AC 44 ms
49,348 KB
testcase_04 AC 45 ms
49,360 KB
testcase_05 AC 45 ms
49,264 KB
testcase_06 AC 45 ms
49,768 KB
testcase_07 AC 44 ms
49,440 KB
testcase_08 AC 44 ms
49,204 KB
testcase_09 AC 42 ms
49,228 KB
testcase_10 AC 42 ms
49,776 KB
testcase_11 AC 42 ms
49,284 KB
testcase_12 AC 42 ms
49,268 KB
testcase_13 AC 43 ms
49,284 KB
testcase_14 AC 42 ms
47,716 KB
testcase_15 AC 43 ms
49,216 KB
testcase_16 AC 155 ms
55,100 KB
testcase_17 AC 181 ms
55,564 KB
testcase_18 AC 89 ms
52,440 KB
testcase_19 AC 189 ms
55,420 KB
testcase_20 AC 131 ms
55,156 KB
testcase_21 AC 105 ms
52,460 KB
testcase_22 AC 175 ms
55,840 KB
testcase_23 AC 147 ms
55,308 KB
testcase_24 AC 175 ms
56,040 KB
testcase_25 AC 111 ms
54,416 KB
testcase_26 AC 151 ms
55,764 KB
testcase_27 AC 195 ms
56,220 KB
testcase_28 AC 155 ms
55,852 KB
testcase_29 AC 176 ms
55,708 KB
testcase_30 AC 151 ms
56,016 KB
testcase_31 AC 113 ms
54,632 KB
testcase_32 AC 124 ms
54,616 KB
testcase_33 AC 193 ms
55,972 KB
testcase_34 AC 96 ms
52,288 KB
testcase_35 AC 160 ms
54,928 KB
testcase_36 AC 186 ms
56,132 KB
testcase_37 AC 190 ms
55,860 KB
testcase_38 AC 195 ms
55,872 KB
testcase_39 AC 189 ms
56,176 KB
testcase_40 AC 187 ms
55,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int[] values = new int[n];
        for (int i = 0; i < n; i++) {
            values[i] = sc.nextInt();
        }
        int idx = n - 1;
        int ans = n;
        for (int i = n; i >= 1 && idx >= 0; i--) {
            while (idx >= 0 && values[idx] != i) {
                idx--;
            }
            if (idx < 0) {
                break;
            }
            idx--;
            ans--;
        }
        System.out.println(ans);
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0