結果
問題 | No.123 カードシャッフル |
ユーザー |
![]() |
提出日時 | 2017-04-29 09:34:16 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 182 ms / 5,000 ms |
コード長 | 803 bytes |
コンパイル時間 | 2,275 ms |
コンパイル使用メモリ | 74,632 KB |
実行使用メモリ | 50,120 KB |
最終ジャッジ日時 | 2024-09-13 19:09:20 |
合計ジャッジ時間 | 4,058 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 10 |
ソースコード
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);}}