結果
| 問題 |
No.586 ダブルブッキング
|
| コンテスト | |
| ユーザー |
Common Lisp
|
| 提出日時 | 2024-10-11 16:17:46 |
| 言語 | Common Lisp (sbcl 2.5.0) |
| 結果 |
AC
|
| 実行時間 | 9 ms / 2,000 ms |
| コード長 | 1,168 bytes |
| コンパイル時間 | 1,936 ms |
| コンパイル使用メモリ | 28,160 KB |
| 実行使用メモリ | 21,760 KB |
| 最終ジャッジ日時 | 2024-10-11 16:17:49 |
| 合計ジャッジ時間 | 2,797 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 11 OCT 2024 04:17:46 PM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.029
ソースコード
; ハッシュ表に予約された部屋番号と予約数のペアを書いていく
; ハッシュ表内を走査し予約数が2以上であれば都度(p1+p2)*(予約数-1)を足していく
(defun main (&rest argv)
(declare (ignorable argv))
(let* ((p1 (read))
(p2 (read))
(p (+ p1 p2))
(n (read))
; https://cl-community-spec.github.io/pages/make_002dhash_002dtable.html
; make-hash-table &key test size rehash-size rehash-threshold ⇒ hash-table
(tabl (make-hash-table)))
(dotimes (_ n)
; https://cl-community-spec.github.io/pages/gethash.html
; gethash key hash-table &optional default ⇒ value, present-p
(incf (gethash (read) tabl 0)))
; https://cl-community-spec.github.io/pages/loop.html
; for-as-hash ::= var [type-spec] being {each | the} {{hash-key | hash-keys} {in | of} hash-table [using (hash-value other-var)] | {hash-value | hash-values} {in | of} hash-table [using (hash-key other-var)]}
(princ (loop for value being each hash-values of tabl
sum (* (1- value) p)))
(terpri)))
(main)
Common Lisp