Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
<?php
$L = trim(fgets(STDIN));
$N = trim(fgets(STDIN));
$boxes = explode(' ',trim(fgets(STDIN)));
sort($boxes);
$len = 0;
for($i = 0; $i < $N;) {
if($L >= ($len + $boxes[$i])) {
$len += $boxes[$i];
$i++;
} else {
break;
}
}
echo $i.PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment