using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace StartFinish { class Putin { public static int bighaba(int haba) { if (haba <= 1 || haba <= 10000) { return haba; } Console.WriteLine("正しい値を入力してください。"); return 0; } public static int smallhaba(int haba) { if (haba <= 1 || haba <= 10000) { return haba; } Console.WriteLine("正しい値を入力してください。"); return 0; } } class Program { static void Main(string[] args) { bool flag = true; while (flag) { Console.WriteLine("大きな箱の幅を入力してください"); int L = Putin.bighaba(int.Parse(Console.ReadLine())); if (L == 0) { continue; } Console.WriteLine("ブロックの数を入力してください。"); int N = Putin.smallhaba(int.Parse(Console.ReadLine())); if (N == 0) { continue; } List Wlist = new List(); Console.WriteLine("各ブロックの幅を入力してください"); for(int i = 0; i < N; i++) { Wlist.Add(int.Parse(Console.ReadLine())); } Wlist.Sort(); for (int i = 0; (L>=0)&(i!=Wlist.Count) ; ++i) { L -= Wlist[i]; if(i>=1) Console.Write("{0} ",Wlist[i-1]); } flag = false; } } } }