結果
問題 | No.561 東京と京都 |
ユーザー | 明智重蔵 |
提出日時 | 2017-08-27 08:59:08 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 34 ms / 2,000 ms |
コード長 | 3,021 bytes |
コンパイル時間 | 1,951 ms |
コンパイル使用メモリ | 109,184 KB |
実行使用メモリ | 19,712 KB |
最終ジャッジ日時 | 2024-04-23 23:55:34 |
合計ジャッジ時間 | 3,613 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 33 ms
19,456 KB |
testcase_01 | AC | 34 ms
19,328 KB |
testcase_02 | AC | 33 ms
19,328 KB |
testcase_03 | AC | 34 ms
19,328 KB |
testcase_04 | AC | 33 ms
19,584 KB |
testcase_05 | AC | 33 ms
19,456 KB |
testcase_06 | AC | 33 ms
19,584 KB |
testcase_07 | AC | 32 ms
19,456 KB |
testcase_08 | AC | 33 ms
19,328 KB |
testcase_09 | AC | 33 ms
19,328 KB |
testcase_10 | AC | 34 ms
19,456 KB |
testcase_11 | AC | 34 ms
19,456 KB |
testcase_12 | AC | 33 ms
19,712 KB |
testcase_13 | AC | 33 ms
19,328 KB |
testcase_14 | AC | 33 ms
19,328 KB |
testcase_15 | AC | 33 ms
19,712 KB |
testcase_16 | AC | 32 ms
19,584 KB |
testcase_17 | AC | 33 ms
19,456 KB |
testcase_18 | AC | 33 ms
19,584 KB |
testcase_19 | AC | 32 ms
19,456 KB |
testcase_20 | AC | 33 ms
19,584 KB |
コンパイルメッセージ
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 = "InputX"; static List<string> GetInputList() { var WillReturn = new List<string>(); if (InputPattern == "Input1") { WillReturn.Add("2 10000"); WillReturn.Add("20000 32000"); WillReturn.Add("24000 23000"); //45000 } else if (InputPattern == "Input2") { WillReturn.Add("2 10000"); WillReturn.Add("42000 50000"); WillReturn.Add("58000 56000"); //100000 } else if (InputPattern == "Input3") { WillReturn.Add("3 10"); WillReturn.Add("42000 50000"); WillReturn.Add("58000 56000"); WillReturn.Add("40000 45000"); //152970 } else if (InputPattern == "Input4") { WillReturn.Add("5 3000"); WillReturn.Add("10000 10000"); WillReturn.Add("20000 23000"); WillReturn.Add("30000 38000"); WillReturn.Add("44000 40000"); WillReturn.Add("54000 56000"); //164000 } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } struct TKInfoDef { internal int T; internal int K; } static void Main() { List<string> InputList = GetInputList(); int[] wkArr = { }; Action<string> SplitAct = pStr => wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray(); SplitAct(InputList[0]); int D = wkArr[1]; var TKInfoList = new List<TKInfoDef>(); foreach (string EachStr in InputList.Skip(1)) { SplitAct(EachStr); TKInfoList.Add(new TKInfoDef() { T = wkArr[0], K = wkArr[1] }); } //収入合計[Is東京]なDP表 var PrevDP = new Dictionary<bool, int>(); PrevDP[true] = 0; foreach (TKInfoDef EachTKInfo in TKInfoList) { var CurrDP = new Dictionary<bool, int>(); Action<bool, int> UpdateAct = (pKey, pValue) => { if (CurrDP.ContainsKey(pKey) && CurrDP[pKey] >= pValue) return; CurrDP[pKey] = pValue; }; foreach (var EachPair in PrevDP) { //東京で働く場合 if (EachPair.Key) UpdateAct(true, EachPair.Value + EachTKInfo.T); else UpdateAct(true, EachPair.Value + EachTKInfo.T - D); //京都で働く場合 if (EachPair.Key) UpdateAct(false, EachPair.Value + EachTKInfo.K - D); else UpdateAct(false, EachPair.Value + EachTKInfo.K); } PrevDP = CurrDP; } Console.WriteLine(PrevDP.Values.Max()); } }