結果
問題 | No.505 カードの数式2 |
ユーザー | 14番 |
提出日時 | 2017-04-21 22:56:06 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,919 bytes |
コンパイル時間 | 2,308 ms |
コンパイル使用メモリ | 106,772 KB |
実行使用メモリ | 123,100 KB |
最終ジャッジ日時 | 2023-09-27 12:22:37 |
合計ジャッジ時間 | 8,104 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 73 ms
23,840 KB |
testcase_01 | AC | 76 ms
21,840 KB |
testcase_02 | AC | 85 ms
24,156 KB |
testcase_03 | AC | 71 ms
21,912 KB |
testcase_04 | AC | 70 ms
24,060 KB |
testcase_05 | AC | 74 ms
23,900 KB |
testcase_06 | AC | 72 ms
21,844 KB |
testcase_07 | AC | 71 ms
21,892 KB |
testcase_08 | AC | 74 ms
24,076 KB |
testcase_09 | AC | 72 ms
21,836 KB |
testcase_10 | AC | 74 ms
21,980 KB |
testcase_11 | WA | - |
testcase_12 | AC | 72 ms
24,008 KB |
testcase_13 | AC | 73 ms
21,840 KB |
testcase_14 | AC | 72 ms
21,920 KB |
testcase_15 | AC | 73 ms
21,888 KB |
testcase_16 | AC | 75 ms
23,972 KB |
testcase_17 | WA | - |
testcase_18 | AC | 74 ms
19,880 KB |
testcase_19 | AC | 73 ms
22,020 KB |
testcase_20 | AC | 74 ms
21,960 KB |
testcase_21 | AC | 74 ms
21,852 KB |
testcase_22 | AC | 273 ms
56,172 KB |
testcase_23 | AC | 110 ms
28,824 KB |
testcase_24 | AC | 75 ms
21,840 KB |
testcase_25 | AC | 74 ms
21,884 KB |
testcase_26 | AC | 352 ms
61,156 KB |
testcase_27 | AC | 341 ms
61,452 KB |
testcase_28 | AC | 1,215 ms
123,100 KB |
testcase_29 | WA | - |
testcase_30 | AC | 73 ms
22,016 KB |
testcase_31 | AC | 342 ms
59,208 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.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; this.ItemCount = int.Parse(Reader.ReadLine()); this.Items = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray(); decimal ans = GetAns(1, this.Items[0]); Console.WriteLine(ans); } private int[] Items; private int ItemCount = 0; private Dictionary<int, Dictionary<decimal, decimal>> dic = new Dictionary<int, Dictionary<decimal, decimal>>(); private decimal GetAns(int idx, decimal subTotal) { if (idx >= ItemCount) { return subTotal; } if (!dic.ContainsKey(idx)) { dic.Add(idx, new Dictionary<decimal, decimal>()); } if (dic[idx].ContainsKey(subTotal)) { return dic[idx][subTotal]; } decimal ans = 0; int num = Items[idx]; ans = GetAns(idx + 1, subTotal + num); ans = Math.Max(ans, GetAns(idx + 1, subTotal - num)); ans = Math.Max(ans, GetAns(idx + 1, subTotal * num)); dic[idx][subTotal] = ans; return ans; } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 16 6 9 1 2 1 2 1 2 1 4 1 4 1 8 1 2 "; 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(); } } } static void Main() { Program prg = new Program(); prg.Proc(); } }