結果

問題 No.123 カードシャッフル
ユーザー bayashiko_rbayashiko_r
提出日時 2018-11-30 01:12:41
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 933 bytes
コンパイル時間 2,052 ms
コンパイル使用メモリ 100,216 KB
実行使用メモリ 30,204 KB
最終ジャッジ日時 2023-09-09 05:57:50
合計ジャッジ時間 3,982 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
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 -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;

class Program {
    static void Main(string[] args) {
        //入力
        string s = Console.ReadLine();
        string x = Console.ReadLine();

        string[] t = s.Split(' ');
        int N = int.Parse(t[0]);
        int M = int.Parse(t[1]);
        
        string[] y = x.Split(' ');
        int[] A = new int[M];
        
        for (int i = 0; i < M; i++) {
            A[i] = int.Parse(y[i]);
        }

        var list = new List<int> { };
        for (int i = 0; i < N; i++) {
            list.Add(N - i);
        }

        list.Add(list[A[0] - 1]);

        //入れ替え
        for (int i = 0; i < M; i++) {
            list.Insert(0, list[A[i] - 1]);  //先頭にi番目の要素を加える
            list.RemoveRange(A[i + 1], 1);  //先ほどまでi番目にいた数を削除する
        }

        //出力
        Console.WriteLine(list[0]);
    }
}
0