結果

問題 No.123 カードシャッフル
ユーザー bayashiko_rbayashiko_r
提出日時 2018-11-30 00:58:31
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 897 bytes
コンパイル時間 4,140 ms
コンパイル使用メモリ 99,648 KB
実行使用メモリ 29,984 KB
最終ジャッジ日時 2023-09-09 05:57:41
合計ジャッジ時間 4,138 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 58 ms
22,944 KB
testcase_02 AC 57 ms
22,788 KB
testcase_03 WA -
testcase_04 AC 58 ms
22,868 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 57 ms
22,724 KB
testcase_09 AC 58 ms
20,764 KB
testcase_10 AC 93 ms
23,368 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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[] t = s.Split(' ');
        int N = int.Parse(t[0]);
        int M = int.Parse(t[1]);
        string x = Console.ReadLine();
        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(i + 1);
        }

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

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