結果
問題 | No.149 碁石の移動 |
ユーザー |
![]() |
提出日時 | 2015-08-16 17:53:21 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 32 ms / 2,000 ms |
コード長 | 2,869 bytes |
コンパイル時間 | 4,472 ms |
コンパイル使用メモリ | 107,136 KB |
実行使用メモリ | 19,200 KB |
最終ジャッジ日時 | 2024-12-24 03:09:34 |
合計ジャッジ時間 | 2,587 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 13 |
コンパイルメッセージ
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; class Program { static string InputPattern = "Input5"; static List<string> GetInputList() { var WillReturn = new List<string>(); if (InputPattern == "Input1") { WillReturn.Add("2 1"); WillReturn.Add("1 2"); WillReturn.Add("2 3"); } else if (InputPattern == "Input2") { WillReturn.Add("2 0"); WillReturn.Add("0 3"); WillReturn.Add("2 1"); } else if (InputPattern == "Input3") { WillReturn.Add("3 0"); WillReturn.Add("2 3"); WillReturn.Add("0 5"); } else if (InputPattern == "Input4") { WillReturn.Add("43682 82641"); WillReturn.Add("54647 3647"); WillReturn.Add("92674 64591"); } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List<string> InputList = GetInputList(); int[] wkArr = { }; Action<int> SplitAct = (pIndY) => wkArr = InputList[pIndY].Split(' ').Select(X => int.Parse(X)).ToArray(); int ACntWhite, ACntBlack; int BCntWhite, BCntBlack; int TakeCntFromA, TakeCntFromB; SplitAct(0); ACntWhite = wkArr[0]; ACntBlack = wkArr[1]; SplitAct(1); BCntWhite = wkArr[0]; BCntBlack = wkArr[1]; SplitAct(2); TakeCntFromA = wkArr[0]; TakeCntFromB = wkArr[1]; Action DebugPrintAct = () => { //Console.WriteLine(new string('■', 20)); //Console.WriteLine("袋Aの白={0}、黒={1}。袋Bの白={2}、黒={3}", // ACntWhite, ACntBlack, BCntWhite, BCntBlack); }; DebugPrintAct(); //Aの袋からBの袋への移動 if (TakeCntFromA <= ACntBlack) { ACntBlack -= TakeCntFromA; BCntBlack += TakeCntFromA; } else { int FirstMoveCnt = ACntBlack; ACntBlack = 0; BCntBlack += FirstMoveCnt; int SecondMoveCnt = TakeCntFromA - FirstMoveCnt; ACntWhite -= SecondMoveCnt; BCntWhite += SecondMoveCnt; } DebugPrintAct(); //Bの袋からAの袋への移動 if (TakeCntFromB <= BCntWhite) { BCntWhite -= TakeCntFromB; ACntWhite += TakeCntFromB; } else { int FirstMoveCnt = BCntWhite; BCntWhite = 0; ACntWhite += FirstMoveCnt; int SecondMoveCnt = TakeCntFromB - FirstMoveCnt; BCntBlack -= SecondMoveCnt; ACntBlack += SecondMoveCnt; } DebugPrintAct(); Console.WriteLine(ACntWhite); } }