結果
問題 | No.286 Modulo Discount Store |
ユーザー | 14番 |
提出日時 | 2016-05-15 00:28:54 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 447 ms / 2,000 ms |
コード長 | 1,903 bytes |
コンパイル時間 | 1,140 ms |
コンパイル使用メモリ | 114,548 KB |
実行使用メモリ | 34,700 KB |
最終ジャッジ日時 | 2024-04-15 21:37:06 |
合計ジャッジ時間 | 4,463 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 28 ms
24,120 KB |
testcase_01 | AC | 29 ms
23,892 KB |
testcase_02 | AC | 112 ms
30,728 KB |
testcase_03 | AC | 29 ms
23,980 KB |
testcase_04 | AC | 30 ms
26,316 KB |
testcase_05 | AC | 29 ms
26,156 KB |
testcase_06 | AC | 210 ms
32,024 KB |
testcase_07 | AC | 27 ms
23,892 KB |
testcase_08 | AC | 29 ms
24,372 KB |
testcase_09 | AC | 27 ms
21,944 KB |
testcase_10 | AC | 62 ms
28,100 KB |
testcase_11 | AC | 27 ms
26,172 KB |
testcase_12 | AC | 27 ms
26,028 KB |
testcase_13 | AC | 106 ms
30,868 KB |
testcase_14 | AC | 27 ms
24,364 KB |
testcase_15 | AC | 25 ms
22,204 KB |
testcase_16 | AC | 27 ms
26,060 KB |
testcase_17 | AC | 447 ms
34,700 KB |
testcase_18 | AC | 63 ms
28,352 KB |
testcase_19 | AC | 27 ms
23,988 KB |
testcase_20 | AC | 32 ms
24,396 KB |
testcase_21 | AC | 26 ms
22,064 KB |
testcase_22 | AC | 27 ms
24,108 KB |
testcase_23 | AC | 103 ms
30,612 KB |
testcase_24 | AC | 27 ms
22,192 KB |
testcase_25 | AC | 44 ms
30,328 KB |
testcase_26 | AC | 27 ms
23,892 KB |
testcase_27 | AC | 43 ms
28,144 KB |
testcase_28 | AC | 209 ms
32,156 KB |
testcase_29 | AC | 28 ms
24,004 KB |
testcase_30 | AC | 28 ms
24,144 KB |
testcase_31 | AC | 31 ms
24,160 KB |
testcase_32 | AC | 30 ms
26,216 KB |
testcase_33 | AC | 27 ms
24,108 KB |
testcase_34 | AC | 27 ms
22,068 KB |
testcase_35 | AC | 28 ms
24,156 KB |
testcase_36 | AC | 26 ms
23,640 KB |
testcase_37 | AC | 45 ms
30,308 KB |
testcase_38 | AC | 28 ms
23,984 KB |
testcase_39 | AC | 209 ms
32,136 KB |
testcase_40 | AC | 28 ms
22,328 KB |
testcase_41 | AC | 26 ms
24,108 KB |
testcase_42 | AC | 27 ms
24,280 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; int itemCount = int.Parse(Reader.ReadLine()); for (int i = 0; i < itemCount; i++) { this.priceList.Add(int.Parse(Reader.ReadLine())); } int ans = this.GetAns(this.priceList, 0); Console.WriteLine(ans); } private Dictionary<string, int> dic = new Dictionary<string, int>(); private int GetAns(List<int> target, int nebiki) { string key = string.Join("#", target); if (dic.ContainsKey(key)) { return dic[key]; } if (target.Count == 1) { return Math.Max(0, target[0] - nebiki); } int ans = int.MaxValue ; for (int i = 0; i < target.Count; i++) { List<int> subList = new List<int>(target); subList.RemoveAt(i); ans = Math.Min(ans, this.GetAns(subList, (nebiki + target[i]) % 1000) + (Math.Max(0, target[i] - nebiki))); } dic.Add(key, ans); return ans; } public List<int> priceList = new List<int>(); public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 5 10000 1000 100 10 1 "; 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(); } }