結果

問題 No.37 遊園地のアトラクション
ユーザー 14番14番
提出日時 2016-05-29 19:26:29
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 2,215 bytes
コンパイル時間 996 ms
コンパイル使用メモリ 115,780 KB
実行使用メモリ 118,176 KB
最終ジャッジ日時 2024-04-16 18:16:57
合計ジャッジ時間 14,420 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3,372 ms
48,744 KB
testcase_01 AC 33 ms
19,584 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int maxTaizai = int.Parse(Reader.ReadLine());
        int inputCount = int.Parse(Reader.ReadLine());
        
        this.MachijikanList = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray();
        
        int[] manzoku = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray();

        int ans = this.GetAns(manzoku, maxTaizai);
        Console.WriteLine(ans);
    }
    
    private Dictionary<string, Dictionary<int, int>> dic = new Dictionary<string, Dictionary<int, int>>();
    
    private int GetAns(int[] manzoku, int remain) {
        string key = string.Join("#", manzoku);
        if(!dic.ContainsKey(key)) {
            dic.Add(key, new Dictionary<int, int>());
        }
        if(dic[key].ContainsKey(remain)) {
            return dic[key][remain];
        }
        
        if(remain == 0) {
            return 0;
        }
        
        int ans = 0;
        for(int i=0; i<this.MachijikanList.Length; i++) {
            if(this.MachijikanList[i] <= remain) {
                int[] sub = (int[])manzoku.Clone();
                sub[i] = sub[i] / 2;
                int ret = this.GetAns(sub, remain - this.MachijikanList[i]) + manzoku[i];
                ans = Math.Max(ret, ans);
            }
        }
        dic[key].Add(remain, ans);
        return ans;
    }
    
    
    private int[] MachijikanList ;
    

    

    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"


9
2
8 2
9 5





";
        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();
    }
}
0