結果
問題 | No.345 最小チワワ問題 |
ユーザー |
|
提出日時 | 2025-04-04 22:37:56 |
言語 | Common Lisp (sbcl 2.5.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 986 bytes |
コンパイル時間 | 1,358 ms |
コンパイル使用メモリ | 33,224 KB |
実行使用メモリ | 25,660 KB |
最終ジャッジ日時 | 2025-04-04 22:37:59 |
合計ジャッジ時間 | 2,939 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 04 APR 2025 10:37:55 PM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.084
ソースコード
(defvar c) (defvar w) (defvar p) (setq p 1) (setq c nil) (setq w nil) (loop for char = (read-char nil nil) do (case char (#\c (setq c (append c (list p)))) (#\w (setq w (append w (list p)))) (#\Newline (return))) (incf p) ) ;(setq c '(1 3 10)) ;(setq w '(5 8 11)) ;(print c) ;(print w) (defvar X) (defvar Y) (defvar Z) (defvar ans) (defvar m) (setq ans -1) (setq m nil) (loop for i in c do (setq Y nil) (setq Z nil) (setq Y (position-if (lambda (x) (> x i)) w) ) ;(format t "Y=<~d>~%" Y) (if (not (null Y)) (setq Z (nth (+ Y 1) w))) ;(format t "=<~d>~%" (nth (+ Y 1) w)) ;(format t "Z=<~d>~%" Z) (if (and (not (null Y)) (not (null Z))) (progn (setq ans (+ (- Z i) 1) ) ;(format t "ans=<~d> m=<~d>~%" ans m) (setq m (if (null m) ans (if (< ans m) ans m))) )) ) (format t "~d~%" (if (null m) -1 m))