結果
問題 | No.555 世界史のレポート |
ユーザー | 14番 |
提出日時 | 2017-08-11 23:16:01 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,488 bytes |
コンパイル時間 | 1,092 ms |
コンパイル使用メモリ | 110,132 KB |
実行使用メモリ | 25,116 KB |
最終ジャッジ日時 | 2024-10-12 21:49:39 |
合計ジャッジ時間 | 2,614 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 33 ms
23,224 KB |
testcase_01 | AC | 34 ms
25,116 KB |
testcase_02 | AC | 32 ms
19,072 KB |
testcase_03 | AC | 34 ms
19,456 KB |
testcase_04 | AC | 33 ms
19,456 KB |
testcase_05 | AC | 33 ms
19,328 KB |
testcase_06 | AC | 33 ms
19,200 KB |
testcase_07 | AC | 33 ms
19,328 KB |
testcase_08 | AC | 32 ms
19,328 KB |
testcase_09 | AC | 33 ms
19,072 KB |
testcase_10 | AC | 33 ms
19,584 KB |
testcase_11 | AC | 33 ms
19,712 KB |
testcase_12 | AC | 34 ms
19,712 KB |
testcase_13 | AC | 34 ms
19,968 KB |
testcase_14 | WA | - |
testcase_15 | AC | 32 ms
19,712 KB |
testcase_16 | AC | 34 ms
19,584 KB |
testcase_17 | AC | 34 ms
19,584 KB |
testcase_18 | AC | 34 ms
19,328 KB |
testcase_19 | AC | 34 ms
19,456 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.IO; using System.Linq; using System.Collections.Generic; using System.Text; public class Program { public void Proc() { this.MustLength = int.Parse(Reader.ReadLine()); int[] tmp = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray(); this.CopyCost = tmp[0]; this.PasteCost = tmp[1]; this.MinCost = CopyCost; this.MinCost += (MustLength - 1) * this.PasteCost; long ans = GetAns(1, 1, CopyCost); if(ans< 0) { ans = MinCost; } Console.WriteLine(ans); } private Dictionary<int, Dictionary<int, long>> dic = new Dictionary<int, Dictionary<int, long>>(); private long GetAns(int copyLength, int reportLength, long subtotal) { if (subtotal > MinCost) { return -1; } if(reportLength >= MustLength) { this.MinCost = Math.Min(MinCost, subtotal); return subtotal; } if(!dic.ContainsKey(copyLength)) { dic.Add(copyLength, new Dictionary<int, long>()); } if(dic[copyLength].ContainsKey(reportLength)) { return dic[copyLength][reportLength]; } long ans = ((MustLength - reportLength) / copyLength)*PasteCost + subtotal; if((MustLength-reportLength)%copyLength>0) { ans += PasteCost; } long ret = GetAns(copyLength + reportLength, copyLength + reportLength, subtotal + CopyCost + PasteCost); if(ret >= 0) { ans = Math.Min(ans, ret); } ret = GetAns(copyLength, reportLength + copyLength, subtotal + PasteCost); if (ret >= 0) { ans = Math.Min(ans, ret); } if(ans > this.MinCost) { ans = -1; } else { MinCost = ans; } dic[copyLength][reportLength] = ans; return ans; } private long MinCost = 0; private int MustLength; private int CopyCost; private int PasteCost; public class Reader { private static StringReader sr; public static bool IsDebug = false; public static string ReadLine() { if (IsDebug) { if (sr == null) { sr = new StringReader(InputText.Trim()); } return sr.ReadLine(); } else { return Console.ReadLine(); } } private static string InputText = @" 10 1 3 "; } public static void Main(string[] args) { #if DEBUG Reader.IsDebug = true; #endif Program prg = new Program(); prg.Proc(); } }