結果

問題 No.123 カードシャッフル
ユーザー 14番14番
提出日時 2016-04-17 12:43:23
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 64 ms / 5,000 ms
コード長 1,869 bytes
コンパイル時間 863 ms
コンパイル使用メモリ 112,796 KB
実行使用メモリ 31,312 KB
最終ジャッジ日時 2024-04-15 02:14:39
合計ジャッジ時間 1,850 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
26,112 KB
testcase_01 AC 24 ms
25,904 KB
testcase_02 AC 24 ms
24,116 KB
testcase_03 AC 23 ms
23,984 KB
testcase_04 AC 24 ms
24,108 KB
testcase_05 AC 23 ms
25,996 KB
testcase_06 AC 23 ms
24,112 KB
testcase_07 AC 24 ms
24,108 KB
testcase_08 AC 23 ms
24,112 KB
testcase_09 AC 23 ms
23,864 KB
testcase_10 AC 48 ms
28,688 KB
testcase_11 AC 56 ms
28,948 KB
testcase_12 AC 64 ms
31,312 KB
testcase_13 AC 63 ms
29,004 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.Text;
using System.Linq;
 
class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int[] inpt = Reader.GetInt();
        int cardCount = inpt[0];
        int shuffleCount = inpt[1];
        
        List<int> cards = new List<int>();
        for(int i=1; i<=cardCount; i++) {
            cards.Add(i);
        }
        
        int[] shuffle = Reader.GetInt();
        for(int i=0; i<shuffleCount; i++) {
            int idx = shuffle[i] - 1;
            int tmp = cards[idx];
            cards.RemoveAt(idx);
            cards.Insert(0, tmp);
        }
        
        Console.WriteLine(cards[0]);

    }
 
 
 
    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"




10 8
6 10 4 2 7 1 4 3




 
";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        public static int[] GetInt(char delimiter = ' ', bool trim = false)
        {
            string inptStr = ReadLine();
            if (trim)
            {
                inptStr = inptStr.Trim();
            }
            string[] inpt = inptStr.Split(delimiter);
            int[] ret = new int[inpt.Length];
            for (int i = 0; i < inpt.Length; i++)
            {
                ret[i] = int.Parse(inpt[i]);
            }
            return ret;
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}
0