about summary refs log tree commit diff
path: root/codechef/spread2.lisp
blob: db2602462800d9316e7c7872210cb4bcd60e6eab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
(defun next (m result)
  (if (> m 0)
      (next (1- m) (+ (read) result))
      result))

(defun spread2 (n sum &optional (result 1))
  (if (< sum n)
      (spread2 (- n sum) (next sum sum) (1+ result))
      (dotimes (i n result) (read))))

(let ((tests (read)))
  (dotimes (i tests)
    (format t "~a~&" (spread2 (1- (read)) (read)))))