結果

問題 No.123 カードシャッフル
ユーザー fkwnw3_1243fkwnw3_1243
提出日時 2017-04-29 09:34:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 171 ms / 5,000 ms
コード長 803 bytes
コンパイル時間 1,984 ms
コンパイル使用メモリ 71,656 KB
実行使用メモリ 61,036 KB
最終ジャッジ日時 2023-10-11 20:17:58
合計ジャッジ時間 3,893 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,024 KB
testcase_01 AC 43 ms
49,308 KB
testcase_02 AC 43 ms
48,976 KB
testcase_03 AC 44 ms
49,492 KB
testcase_04 AC 43 ms
49,312 KB
testcase_05 AC 43 ms
49,108 KB
testcase_06 AC 43 ms
49,124 KB
testcase_07 AC 43 ms
49,372 KB
testcase_08 AC 43 ms
49,028 KB
testcase_09 AC 43 ms
49,208 KB
testcase_10 AC 155 ms
58,876 KB
testcase_11 AC 166 ms
58,944 KB
testcase_12 AC 171 ms
61,036 KB
testcase_13 AC 167 ms
60,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String[] inputs = reader.readLine().split(" ");
        int N = Integer.parseInt(inputs[0]);
        int M = Integer.parseInt(inputs[1]);
        inputs = reader.readLine().split(" ");
        int top = 1;
        for (int i = M - 1; i > -1; i--) {
            int a = Integer.parseInt(inputs[i]);
            if (top == 1) {
                top = a;
            } else if (top <= a) {
                top -= 1;
            }
        }
        System.out.println(top);
    }
}
0