using System; using System.Collections.Generic; public class Program { public void Proc() { Reader.IsDebug = false; int[] inpt = Reader.GetInt(); int itemCount = inpt[0]; int seiyakuCount = inpt[1]; for(int i=0; i targetNum = new List(); for(int i=0; i> list = this.GetList(targetNum); int ans = 0; foreach (List subList in list) { ans = Math.Max(ans, this.GetScore(subList)); } Console.WriteLine(ans); } private int GetScore(List target) { int ans = 0; foreach (Seiyaku se in this.SeiyakuList) { int idx1 = target.IndexOf(se.Before); int idx2 = target.IndexOf(se.After); if(idx1 < idx2) { ans += se.Point; } } return ans; } private List> GetList(List target) { List> ans = new List>(); if(target.Count == 1) { List num = new List(); num.Add(target[0]); ans.Add(num); return ans; } for(int i=0; i subList = new List(); subList.AddRange(target); subList.RemoveAt(i); List> ret = this.GetList(subList); foreach (List retSub in ret) { List tmp = new List(); retSub.Add(target[i]); ans.Add(retSub); } } return ans; } private List SeiyakuList = new List(); public class Seiyaku { public int Before; public int After; public int Point; public Seiyaku(int[] init) { this.Before = init[0]; this.After = init[1]; this.Point = init[2]; } } public class Reader { private static String InitText = @" 4 9 0 1 1 0 2 2 0 3 3 1 2 4 1 3 5 2 3 6 3 2 100 2 1 100 1 0 100 "; private static System.IO.StringReader sr = null; public static bool IsDebug = true; public static string ReadLine() { if(IsDebug) { if(sr == null) { sr = new System.IO.StringReader(InitText.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