(define l (string->number (read-line))) (read-line) (define ws (sort (map string->number (string-split (read-line) " ")))) (let loop ((count 0) (total 0) (head (car ws)) (tail (cdr ws))) (let* ((total+ (+ total head)) (overflow? (> total+ l))) (cond (overflow? count) ((null? tail) (+ count 1)) (else (loop (+ count 1) total+ (car tail) (cdr tail))))))