using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int L = int.Parse(args[0]); int N = int.Parse(args[1]); int count = 0; int[] W = new int[args.Length - 2]; for (int i = 0; i < N; i++) { W[i] = int.Parse(args[2 + i]); } Array.Sort(W); while (L > 0) { L = L - W[count]; if (count < W.Length) { if (L > 0) { count++; } } } Console.WriteLine(count); } } }