結果
問題 | No.123 カードシャッフル |
ユーザー | abc |
提出日時 | 2016-11-06 12:39:36 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 463 ms / 5,000 ms |
コード長 | 702 bytes |
コンパイル時間 | 3,422 ms |
コンパイル使用メモリ | 71,452 KB |
実行使用メモリ | 60,828 KB |
最終ジャッジ日時 | 2023-08-16 13:58:07 |
合計ジャッジ時間 | 6,569 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 121 ms
55,620 KB |
testcase_01 | AC | 120 ms
55,728 KB |
testcase_02 | AC | 120 ms
55,880 KB |
testcase_03 | AC | 124 ms
55,856 KB |
testcase_04 | AC | 120 ms
55,808 KB |
testcase_05 | AC | 120 ms
55,860 KB |
testcase_06 | AC | 121 ms
56,044 KB |
testcase_07 | AC | 122 ms
53,792 KB |
testcase_08 | AC | 122 ms
55,988 KB |
testcase_09 | AC | 122 ms
55,784 KB |
testcase_10 | AC | 445 ms
60,828 KB |
testcase_11 | AC | 448 ms
60,636 KB |
testcase_12 | AC | 463 ms
58,148 KB |
testcase_13 | AC | 456 ms
60,520 KB |
ソースコード
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); } }