結果
問題 | No.123 カードシャッフル |
ユーザー |
|
提出日時 | 2018-02-12 15:22:58 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 190 ms / 5,000 ms |
コード長 | 758 bytes |
コンパイル時間 | 3,179 ms |
コンパイル使用メモリ | 75,444 KB |
実行使用メモリ | 62,824 KB |
最終ジャッジ日時 | 2024-11-24 12:57:00 |
合計ジャッジ時間 | 5,288 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 10 |
ソースコード
package me.yukicoder;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.LinkedList;public class No0123 {public static void main(String[] args) throws IOException {BufferedReader br = new BufferedReader(new InputStreamReader(System.in));String[] input1 = br.readLine().split(" ");int n = Integer.parseInt(input1[0]);int m = Integer.parseInt(input1[1]);LinkedList<Integer> list = new LinkedList<>();for (int i = 0; i < n; i++) {list.add(i + 1);}String[] input2 = br.readLine().split(" ");for (int i = 0; i < m; i++) {int idx = Integer.parseInt(input2[i]);int ret = list.remove(idx - 1);list.addFirst(ret);}System.out.println(list.get(0));}}