結果

問題 No.2803 Bocching Star
ユーザー Lisp_Coder
提出日時 2024-07-21 01:06:06
言語 Common Lisp
(sbcl 2.5.0)
結果
WA  
実行時間 -
コード長 1,331 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 29,056 KB
実行使用メモリ 46,336 KB
最終ジャッジ日時 2024-07-21 01:06:11
合計ジャッジ時間 4,572 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other TLE * 1 -- * 34
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 21 JUL 2024 01:06:06 AM):

; wrote /home/judge/data/code/Main.fasl
; compilation finished in 0:00:00.010

ソースコード

diff #

#-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)))
         (indexed-P (loop for i from 0 below N collect (cons (nth i P) (1+ i))))
         (sorted-P (sort indexed-P #'< :key #'car))
         (result '()))
    (loop for i from 1 below N
          for (val1 . idx1) = (nth (1- i) sorted-P)
          for (val2 . idx2) = (nth i sorted-P)
          when (> (- val2 val1) S) do (push idx2 result))
    (let* ((first (first sorted-P))
           (last (first (last sorted-P))))
      (when (> (- (car first) most-negative-fixnum) S)
        (push (cdr first) result))
      (when (> (- most-positive-fixnum (car last)) S)
        (push (cdr last) result)))
    (setf result (sort result #'<))
    (format t "~D~%" (length result))
    (dolist (elem result)
      (format t "~D " elem))
    (terpri)))

(main)
0