結果

問題 No.112 ややこしい鶴亀算
ユーザー まんしmaNNshi
提出日時 2025-04-29 19:08:21
言語 Common Lisp
(sbcl 2.5.0)
結果
AC  
実行時間 9 ms / 5,000 ms
コード長 807 bytes
コンパイル時間 406 ms
コンパイル使用メモリ 27,008 KB
実行使用メモリ 19,712 KB
最終ジャッジ日時 2025-04-29 19:08:23
合計ジャッジ時間 1,837 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 29 APR 2025 07:08:21 PM):

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

ソースコード

diff #

(defparameter x (make-hash-table))


(defparameter N (parse-integer (read-line)))
(defparameter a (read-from-string (concatenate 'string "(" (read-line) ")" )))

(defparameter big 0)
(defparameter small 0)

(loop for i in a do

        (if (null (gethash i x)) (setf (gethash i x) 1) (setf (gethash i x) (+ (gethash i x) 1)))


        (if (= small 0) (setq small i)
                (if (< small i) (setq big i)
                        (if (> small i)
                                (progn (setq big small) (setq small i)))))


)

;(format t "small=~d big=~d N=~d~%" small big N)

(if (or (= small 0) (= big 0))
        (if (= (/ small 4) (- N 1))
                (format t "~d ~d~%"  0 N)
                (format t "~d ~d~%"  N 0)
        )
        (format t "~d ~d~%" (gethash big x) (gethash small x))
)
0