fun main() { val L = readLine()!!.toInt() val N = readLine()!!.toInt() val W = readLine()!!.split(" ").map(String::toInt) var dp = Array(W.size + 1) { Array(L + 1){ 0 to 0 } } for(i in 1..W.size) for(k in 0..L) { if(W[i-1] + dp[i-1][k].first <= k){ dp[i][k] = (dp[i-1][k].first + W[i-1] to dp[i-1][k].second + 1) }else{ dp[i][k] = dp[i-1][k] } } println(dp.map{ it.maxBy{ it.second }!!.second }.max()) }