using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; int hakoCount = int.Parse(Reader.ReadLine()); HakoList = new Hako[hakoCount]; for (int i = 0; i < hakoCount; i++) { HakoList[i] = new Hako(Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray()); } HakoList = HakoList.OrderByDescending(a => a.Tate).ThenByDescending(a => a.Yoko).ThenByDescending(a => a.Takasa).ToArray(); int ans = GetAns(0, HakoList[0].Tate+1, HakoList[0].Tate+1, HakoList[0].Tate+1); Console.WriteLine(ans); } private int GetAns(int idx, int tate, int yoko, int takasa) { if (idx >= HakoList.Length) { return 0; } if (!dic.ContainsKey(idx)) { dic.Add(idx, new Dictionary>>()); } if (!dic[idx].ContainsKey(tate)) { dic[idx].Add(tate, new Dictionary>()); } if(!dic[idx][tate].ContainsKey(yoko)) { dic[idx][tate].Add(yoko, new Dictionary()); } if(dic[idx][tate][yoko].ContainsKey(takasa)) { return dic[idx][tate][yoko][takasa]; } int ans = 0; int ret = 0; if(HakoList[idx].Tate < tate && HakoList[idx].Yoko >>> dic = new Dictionary>>>(); private Hako[] HakoList; private struct Hako { public int Tate; public int Yoko; public int Takasa; public Hako(int[] inpt) { int[] tmp = inpt.OrderByDescending(a => a).ToArray(); this.Tate = tmp[0]; this.Yoko = tmp[1]; this.Takasa = tmp[2]; } } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 4 2 2 2 1 1 1 3 3 3 4 1 4 "; 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(); } }