-
-
Save papinianus/19de4f1a3f1913fb48a4cec18cae41d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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