結果

問題 No.123 カードシャッフル
ユーザー NoNo
提出日時 2015-06-23 23:05:51
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 109 ms / 5,000 ms
コード長 1,236 bytes
コンパイル時間 2,262 ms
コンパイル使用メモリ 111,232 KB
実行使用メモリ 27,796 KB
最終ジャッジ日時 2023-09-22 00:18:01
合計ジャッジ時間 4,242 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
20,752 KB
testcase_01 AC 60 ms
20,764 KB
testcase_02 AC 62 ms
22,964 KB
testcase_03 AC 60 ms
20,740 KB
testcase_04 AC 60 ms
20,732 KB
testcase_05 AC 61 ms
22,780 KB
testcase_06 AC 60 ms
20,824 KB
testcase_07 AC 60 ms
20,828 KB
testcase_08 AC 61 ms
22,848 KB
testcase_09 AC 60 ms
20,788 KB
testcase_10 AC 90 ms
25,460 KB
testcase_11 AC 100 ms
25,808 KB
testcase_12 AC 109 ms
27,740 KB
testcase_13 AC 107 ms
27,796 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace foryuki
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split() ;
            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);
            var a = ConvertStringArrayToIntArray(Console.ReadLine().Split());

            var li = new List<int>();
            for (int i = 0; i < n; i++)
            {
                li.Add(i + 1);
            }

            for (int i = 0; i < a.Length; i++)
            {
                int w = li[a[i] - 1];
                li.RemoveAt(a[i] - 1);
                li.Insert(0, w);
            }

            Console.WriteLine(li[0]);
        }

        //-------------------------------------------------------------

        static int[] ConvertStringArrayToIntArray(string[] array)
        {
            return Array.ConvertAll(array, str => int.Parse(str));
        }

        static List<int> ConvertStringArrayToIntList(string[] str)
        {
            var list = new List<int>();
            foreach (var c in str) list.Add(int.Parse(c));
            return list;
        }
    }
}
0