using System; using System.Collections.Generic; using System.Text; public class Program { public void Proc(){ Reader.IsDebug = false; int stageCount = int.Parse(Reader.ReadLine()); List targetList = new List(); for(int i=0; i dic = new Dictionary(); private int GetAns(List target) { if(target.Count == 0) { return 0; } string key = string.Join("#", target); if(dic.ContainsKey(key)) { return dic[key]; } int ans = int.MaxValue; for(int i=0; i subList = new List(); subList.AddRange(target); subList.RemoveAt(i); ans = Math.Min(ans, GetAns(subList) + nanido); } this.dic[key] = ans; return ans; } private List StageList = new List(); public class Nanido { public int Stage = 0; public int BeforeStage = 0; public int Value = 0; public Nanido(int stageNum, int beforeStage, int nan) { this.Stage = stageNum; this.BeforeStage = beforeStage; this.Value = nan; } } public static void Main(string[] args) { Program prg = new Program(); prg.Proc(); } } class Reader { public static bool IsDebug = true; private static System.IO.StringReader sr; public static string ReadLine() { if(IsDebug) { if(sr == null) { sr = new System.IO.StringReader(initStr.Trim()); } return sr.ReadLine(); } else { return Console.ReadLine(); } } public static int[] GetInt(char delimiter = ' ') { string[] inpt = ReadLine().Split(delimiter); int[] ret = new int[inpt.Length]; for(int i=0; i