using System; using System.Linq; using System.Text; using System.Collections.Generic; public class Program { public void Proc() { Reader.IsDebug = false; int[] inpt = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray(); int teamCount = inpt[0]; int passCount = inpt[1]; Dictionary>> dic = new Dictionary>>(); Dictionary univCount = new Dictionary(); for(int i=0; iint.Parse(a)).ToArray(); if(!dic.ContainsKey(inpt[0])) { dic.Add(inpt[0], new Dictionary>()); } if(!dic[inpt[0]].ContainsKey(inpt[2])) { dic[inpt[0]].Add(inpt[2], new Dictionary()); } dic[inpt[0]][inpt[2]][inpt[1]] = i; univCount[inpt[2]] = 0; } int cnt = 0; StringBuilder ans = new StringBuilder(); foreach(int acCount in dic.Keys.OrderByDescending(a=>a)) { if(cnt >= passCount) { break; } int must = Math.Min(passCount-cnt, dic[acCount].Sum(a=>a.Value.Count())); for(int i=0; iunivCount[a]).ToArray(); un = un.Where(a=>a==un.Max()).ToArray(); un = un.OrderBy(a=>dic[acCount][a].Min(b=>b.Key)).ToArray(); univ = un[0]; int penalty = dic[acCount][univ].Keys.Min(); ans.AppendLine(dic[acCount][univ][penalty].ToString()); univCount[univ]++; cnt++; dic[acCount][univ].Remove(penalty); if(dic[acCount][univ].Count == 0) { dic[acCount].Remove(univ); } } } Console.Write(ans.ToString()); } public class Reader { public static bool IsDebug = true; private static System.IO.StringReader SReader; private static string InitText = @" 5 3 3 100 1 4 200 1 4 300 1 3 150 2 2 50 2 "; public static string ReadLine() { if(IsDebug) { if(SReader == null) { SReader = new System.IO.StringReader(InitText.Trim()); } return SReader.ReadLine(); } else { return Console.ReadLine(); } } } public static void Main(string[] args) { Program prg = new Program(); prg.Proc(); } }