結果

問題 No.123 カードシャッフル
ユーザー abcabc
提出日時 2016-11-06 12:37:00
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 694 bytes
コンパイル時間 1,816 ms
コンパイル使用メモリ 74,196 KB
実行使用メモリ 55,060 KB
最終ジャッジ日時 2024-05-03 22:19:45
合計ジャッジ時間 4,167 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 120 ms
40,864 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
権限があれば一括ダウンロードができます

ソースコード

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[numCards];

        for (int i = 0; i < numCards; 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