using System; using System.IO; using System.Linq; using System.Collections.Generic; using System.Text; public class Program { public void Proc() { int memberCount = int.Parse(Reader.ReadLine()); this.mentaiMembers = new Person[memberCount]; for (int i = 0; i < memberCount; i++) { this.mentaiMembers[i] = new Person(Reader.ReadLine()); } Dictionary mentai = new Dictionary(); int mentaiCount = int.Parse(Reader.ReadLine()); int maxBuy = 0; for (int i = 0; i < mentaiCount; i++) { int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray(); int price = inpt[0]; int karasa = inpt[1]; int buy = this.mentaiMembers.Count(a => a.Kane >= price && a.Karasa <= karasa); mentai.Add(i+1, buy); maxBuy = Math.Max(maxBuy, buy); } StringBuilder ans = new StringBuilder(); mentai.Where(a=>a.Value==maxBuy).OrderBy(a=>a.Key).ToList().ForEach(a=>ans.AppendLine(a.Key.ToString())); if(ans.Length>0) { Console.Write(ans.ToString()); } else { Console.WriteLine(0); } } Person[] mentaiMembers; private class Person { public int Kane; public int Karasa; public Person(string inpt) { int[] tmp = inpt.Split(' ').Select(a => int.Parse(a)).ToArray(); this.Kane = tmp[0]; this.Karasa = tmp[1]; } } public class Reader { private static StringReader sr; public static bool IsDebug = false; public static string ReadLine() { if (IsDebug) { if (sr == null) { sr = new StringReader(InputText.Trim()); } return sr.ReadLine(); } else { return Console.ReadLine(); } } private static string InputText = @" 3 6 4 5 2 2 5 2 4 3 5 4 "; } public static void Main(string[] args) { #if DEBUG Reader.IsDebug = true; #endif Program prg = new Program(); prg.Proc(); } }