結果
問題 | No.123 カードシャッフル |
ユーザー |
|
提出日時 | 2018-03-29 13:22:09 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 63 ms / 5,000 ms |
コード長 | 1,754 bytes |
コンパイル時間 | 865 ms |
コンパイル使用メモリ | 103,424 KB |
実行使用メモリ | 24,704 KB |
最終ジャッジ日時 | 2024-06-25 22:08:23 |
合計ジャッジ時間 | 2,354 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 10 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ConsoleApplication2{class Program{static void Main(string[] args){string s1 = Console.ReadLine();string[] t1 = s1.Split(' ');string s2 = Console.ReadLine();string[] t2 = s2.Split(' ');/*string[] t1 = new string[2] { "3", "2"};string[] t2 = new string[2] { "3", "2"};*//*string[] t1 = new string[2] { "3", "1" };string[] t2 = new string[1] { "2" };*//*string[] t1 = new string[2] { "4", "4" };string[] t2 = new string[4] { "1", "1", "1", "1" };*/int cardnum = int.Parse(t1[0]);int shufflenum = int.Parse(t1[1]);int[] stacknum = new int[100000];int[] datanum = new int[100000];for (int i = 0; i < shufflenum; i++){stacknum[i] = int.Parse(t2[i]);}for (int i = 0; i < cardnum; i++){datanum[i] = i + 1;}for (int i = 0; i < shufflenum; i++){int kari = datanum[stacknum[i] - 1];int temp = datanum[0];int temp2 = 0;for (int j = 0; j < stacknum[i] - 1; j++, temp = temp2){temp2 = datanum[j + 1];datanum[j + 1] = temp;}datanum[0] = kari;}Console.WriteLine(datanum[0]);}}}