結果

問題 No.365 ジェンガソート
ユーザー tentententen
提出日時 2023-07-27 16:02:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 228 ms / 2,000 ms
コード長 1,802 bytes
コンパイル時間 3,049 ms
コンパイル使用メモリ 90,244 KB
実行使用メモリ 56,236 KB
最終ジャッジ日時 2024-04-15 03:23:49
合計ジャッジ時間 10,046 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
50,468 KB
testcase_01 AC 57 ms
50,208 KB
testcase_02 AC 57 ms
50,560 KB
testcase_03 AC 59 ms
50,008 KB
testcase_04 AC 54 ms
50,252 KB
testcase_05 AC 55 ms
50,132 KB
testcase_06 AC 55 ms
50,388 KB
testcase_07 AC 54 ms
50,116 KB
testcase_08 AC 55 ms
50,488 KB
testcase_09 AC 57 ms
50,188 KB
testcase_10 AC 59 ms
50,412 KB
testcase_11 AC 55 ms
50,428 KB
testcase_12 AC 55 ms
50,360 KB
testcase_13 AC 62 ms
50,160 KB
testcase_14 AC 57 ms
50,120 KB
testcase_15 AC 56 ms
50,136 KB
testcase_16 AC 174 ms
54,964 KB
testcase_17 AC 190 ms
55,040 KB
testcase_18 AC 105 ms
52,104 KB
testcase_19 AC 184 ms
55,140 KB
testcase_20 AC 148 ms
54,404 KB
testcase_21 AC 143 ms
52,744 KB
testcase_22 AC 187 ms
54,976 KB
testcase_23 AC 174 ms
54,248 KB
testcase_24 AC 174 ms
55,344 KB
testcase_25 AC 128 ms
51,928 KB
testcase_26 AC 183 ms
56,104 KB
testcase_27 AC 195 ms
56,236 KB
testcase_28 AC 189 ms
56,168 KB
testcase_29 AC 194 ms
55,100 KB
testcase_30 AC 189 ms
56,024 KB
testcase_31 AC 147 ms
54,572 KB
testcase_32 AC 140 ms
54,440 KB
testcase_33 AC 186 ms
55,068 KB
testcase_34 AC 121 ms
52,044 KB
testcase_35 AC 199 ms
55,060 KB
testcase_36 AC 228 ms
56,092 KB
testcase_37 AC 221 ms
56,060 KB
testcase_38 AC 193 ms
55,344 KB
testcase_39 AC 217 ms
55,428 KB
testcase_40 AC 194 ms
55,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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 ans = n;
        int current = n;
        for (int i = n - 1; i >= 0; i--) {
            if (values[i] == current) {
                current--;
                ans--;
            }
        }
        System.out.println(ans);
    }
} 
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
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 int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0