using System; using System.Collections.Generic; using System.Linq; //YukiCoder412 花火大会 //http://yukicoder.me/problems/no/412 class Program { static string InputPattern = "InputX"; static List GetInputList() { var WillReturn = new List(); if (InputPattern == "Input1") { WillReturn.Add("2 4 6"); WillReturn.Add("4"); WillReturn.Add("1 3 5 7"); //2 } else if (InputPattern == "Input2") { WillReturn.Add("1 1 1"); WillReturn.Add("4"); WillReturn.Add("1 1 1 1"); //5 } else if (InputPattern == "Input3") { WillReturn.Add("100 100 100"); WillReturn.Add("1"); WillReturn.Add("10"); //0 } else if (InputPattern == "Input4") { WillReturn.Add("15 25 35"); WillReturn.Add("10"); WillReturn.Add("10 20 30 40 50 60 70 80 90 100"); //932 } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List InputList = GetInputList(); int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray(); //昇順にシートを割り当てるのでソートしておく Array.Sort(wkArr); int B = wkArr[0]; int C = wkArr[1]; int D = wkArr[2]; //昇順にシートを割り当てるのでソートしておく int[] EArr = InputList[2].Split(' ').Select(X => int.Parse(X)).ToArray(); Array.Sort(EArr); //場合の数[座れる家族数]なDP表 int[] DPArr = new int[4]; DPArr[0] = 1; foreach (int EachInt in EArr) { for (int I = 3; 0 <= I; I--) { int NewInd = I; if (I == 0 && B <= EachInt) NewInd = 1; if (I == 1 && C <= EachInt) NewInd = 2; if (I == 2 && D <= EachInt) NewInd = 3; //和の法則 DPArr[NewInd] += DPArr[I]; } } Console.WriteLine(DPArr[3]); } }