結果
| 問題 |
No.2803 Bocching Star
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-21 01:10:05 |
| 言語 | Common Lisp (sbcl 2.5.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,321 bytes |
| コンパイル時間 | 204 ms |
| コンパイル使用メモリ | 38,064 KB |
| 実行使用メモリ | 38,428 KB |
| 最終ジャッジ日時 | 2024-07-21 01:10:09 |
| 合計ジャッジ時間 | 3,284 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 3 |
| other | RE * 35 |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 21 JUL 2024 01:10:05 AM): ; file: /home/judge/data/code/Main.lisp ; in: DEFUN MAIN ; (MAP 'STRING #'WRITE-TO-STRING RESULT) ; ; caught WARNING: ; The function WRITE-TO-STRING called by MAP returns SIMPLE-STRING but CHARACTER is expected ; See also: ; The SBCL Manual, Node "Handling of Types" ; file: /home/judge/data/code/Main.lisp ; in: DEFUN MAIN ; (SPLIT-SEQUENCE #\Newline INPUT) ; ; caught STYLE-WARNING: ; undefined function: COMMON-LISP-USER::SPLIT-SEQUENCE ; ; compilation unit finished ; Undefined function: ; SPLIT-SEQUENCE ; caught 1 WARNING condition ; caught 1 STYLE-WARNING condition ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.056
ソースコード
#-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 fast-read-lines ()
(with-open-file (stream *standard-input*
:direction :input
:element-type '(unsigned-byte 8)
:external-format :utf-8)
(let ((content (make-array 1024 :element-type 'character :adjustable t :fill-pointer 0)))
(loop for line = (read-line stream nil)
while line
do (vector-push-extend line content)
(vector-push-extend #\Newline content))
(coerce content 'string))))
(defun fast-write-lines (lines)
(with-open-file (stream *standard-output*
:direction :output
:element-type '(unsigned-byte 8)
:external-format :utf-8)
(loop for line in lines
do (write-string line stream)
(write-char #\Newline stream))))
(defun main ()
(let* ((input (fast-read-lines))
(input-lines (split-sequence #\Newline input))
(N (parse-integer (first input-lines)))
(S (parse-integer (second input-lines)))
(P (mapcar #'parse-integer (subseq input-lines 2 (1+ N))))
(indexed-P (mapcar #'(lambda (x i) (list x (1+ i))) P (loop for i from 0 below N collect i)))
(sorted-P (sort indexed-P #'< :key #'first))
(result '()))
(loop for i from 0 below N
for (value index) = (nth i sorted-P)
for left-diff = (if (> i 0) (- value (first (nth (1- i) sorted-P))) most-positive-fixnum)
for right-diff = (if (< i (1- N)) (- (first (nth (1+ i) sorted-P)) value) most-positive-fixnum)
for near = (min left-diff right-diff)
when (> near S) do (push index result))
(setf result (sort result #'<))
(fast-write-lines (list (write-to-string (length result)) (map 'string #'write-to-string result)))))
(main)