#-swank (unless (member :child-sbcl *features*) (quit :recklessly-p t :unix-status (process-exit-code (run-program *runtime-pathname* `("--control-stack-size" "1024MB" "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options" "--eval" "(push :child-sbcl *features*)" "--script" ,(namestring *load-pathname*)) :output t :error t :input t)))) (defun main () (let* ((N (read)) (S (read)) (P (loop for i from 0 below N collect (read))) (sorted-p (sort (mapcar #'(lambda (x i) (list x (1+ i))) P (loop for i from 0 below N collect i)) #'< :key #'first)) (result '())) (loop for i from 0 below N for (value index) = (nth i sorted-p) for left = (if (> i 0) (- value (first (nth (1- i) sorted-p))) most-positive-fixnum) for right = (if (< i (1- N)) (- (first (nth (1+ i) sorted-p)) value) most-positive-fixnum) for near = (min left right) when (> near S) do (push index result)) (setf result (sort result #'<)) (format t "~D~%" (length result)) (dolist (elem result) (format t "~D " elem)) (terpri))) (main)