結果
問題 |
No.123 カードシャッフル
|
ユーザー |
![]() |
提出日時 | 2016-11-06 12:39:36 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 480 ms / 5,000 ms |
コード長 | 702 bytes |
コンパイル時間 | 1,826 ms |
コンパイル使用メモリ | 73,992 KB |
実行使用メモリ | 59,324 KB |
最終ジャッジ日時 | 2024-11-25 03:17:08 |
合計ジャッジ時間 | 5,405 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 10 |
ソースコード
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); } }