(defun main (&rest argv) (declare (ignorable argv)) (let* ((n (read)) (d (read)) (x (make-array n)) (y (make-array n)) (p 0) (q -100000000000000)) (dotimes (i n) (setf (aref x i) (read)) (setf (aref y i) (read))) (dotimes (i n) (let ((new-p (+ (max p (- q d)) (aref x i))) (new-q (+ (max q (- p d)) (aref y i)))) (setq p new-p) (setq q new-q))) (format t "~d~%" (max p q)))) (main)