結果
| 問題 |
No.291 黒い文字列
|
| ユーザー |
Common Lisp
|
| 提出日時 | 2024-11-11 16:41:49 |
| 言語 | Common Lisp (sbcl 2.5.0) |
| 結果 |
AC
|
| 実行時間 | 41 ms / 2,000 ms |
| コード長 | 1,752 bytes |
| コンパイル時間 | 671 ms |
| コンパイル使用メモリ | 70,132 KB |
| 実行使用メモリ | 25,216 KB |
| 最終ジャッジ日時 | 2024-11-11 16:41:51 |
| 合計ジャッジ時間 | 2,262 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 11 NOV 2024 04:41:49 PM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.246
ソースコード
(defun main (&rest argv)
(declare (ignorable argv))
(let* ((s (read-line))
(dp (make-array (list 2 21 21 21 21) :element-type 'integer :initial-element -1))
(a 0)
(b 1)
(res 0))
(setf (aref dp 0 0 0 0 0) 0)
(loop for c across s do
(dotimes (k 21)
(dotimes (u (1+ k))
(dotimes (r (1+ u))
(dotimes (o (1+ r))
(let ((now (aref dp a k u r o)))
(unless (= now -1)
(setf (aref dp b k u r o) (max (aref dp b k u r o) now))
(when (and (or (char= c #\K) (char= c #\?)) (<= (1+ k) 20))
(setf (aref dp b (1+ k) u r o) (max (aref dp b (1+ k) u r o) now)))
(when (and (or (char= c #\U) (char= c #\?)) (<= (1+ u) k))
(setf (aref dp b k (1+ u) r o) (max (aref dp b k (1+ u) r o) now)))
(when (and (or (char= c #\R) (char= c #\?)) (<= (1+ r) k))
(setf (aref dp b k u (1+ r) o) (max (aref dp b k u (1+ r) o) now)))
(when (and (or (char= c #\O) (char= c #\?)) (<= (1+ o) k))
(setf (aref dp b k u r (1+ o)) (max (aref dp b k u r (1+ o)) now)))
(when (and (or (char= c #\I) (char= c #\?)) (<= (1+ now) o))
(setf (aref dp b k u r o) (max (aref dp b k u r o) (1+ now))))))))))
(rotatef a b))
(dotimes (k 21)
(dotimes (u (1+ k))
(dotimes (r (1+ u))
(dotimes (o (1+ r))
(setq res (max res (aref dp a k u r o)))))))
(format t "~d~%" res)))
(main)
Common Lisp