結果

問題 No.123 カードシャッフル
ユーザー abcabc
提出日時 2016-11-06 12:42:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 565 ms / 5,000 ms
コード長 702 bytes
コンパイル時間 2,139 ms
コンパイル使用メモリ 73,772 KB
実行使用メモリ 48,492 KB
最終ジャッジ日時 2024-05-03 22:20:14
合計ジャッジ時間 6,178 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
41,160 KB
testcase_01 AC 113 ms
39,752 KB
testcase_02 AC 116 ms
40,240 KB
testcase_03 AC 124 ms
41,008 KB
testcase_04 AC 130 ms
41,352 KB
testcase_05 AC 113 ms
40,128 KB
testcase_06 AC 118 ms
40,696 KB
testcase_07 AC 126 ms
41,012 KB
testcase_08 AC 112 ms
39,772 KB
testcase_09 AC 113 ms
40,112 KB
testcase_10 AC 437 ms
46,840 KB
testcase_11 AC 545 ms
48,336 KB
testcase_12 AC 529 ms
48,492 KB
testcase_13 AC 565 ms
48,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int numCards = sc.nextInt();

        int numShuffling = sc.nextInt();

        int[] cards = new int[numShuffling];

        for (int i = 0; i < numShuffling; i++) {
            cards[i] = sc.nextInt();
        }

        int topCard = 1;

        for (int i = numShuffling - 1; i >= 0; i--) {

            if (topCard == 1) {

                topCard = cards[i];

            } else {

                if (topCard <= cards[i]) {
                    topCard--;
                }

            }

        }

        System.out.println(topCard);

    }

}
0