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; string[] strW = args[2].Split(' '); int[] W = new int[N]; for (int i = 0; i < N; i++) { W[i] = int.Parse(strW[i]); } Array.Sort(W); while (L > 0) { L = L - W[count]; if (count < W.Length) { if (L > 0) { count++; } } } Console.WriteLine(count); } } }