= 0; $i++) { $l -= $w[$i]; if ($l <= 0) { break; } $ans++; } echo ($ans.PHP_EOL);