結果

問題 No.1512 作文
ユーザー motoshiramotoshira
提出日時 2021-05-21 22:53:11
言語 Common Lisp
(sbcl 2.3.8)
結果
WA  
実行時間 -
コード長 1,883 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 37,700 KB
実行使用メモリ 78,332 KB
最終ジャッジ日時 2024-04-18 16:20:25
合計ジャッジ時間 2,538 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 15 ms
33,064 KB
testcase_10 AC 16 ms
32,932 KB
testcase_11 AC 16 ms
33,040 KB
testcase_12 AC 18 ms
33,044 KB
testcase_13 AC 19 ms
32,928 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 9 ms
26,536 KB
testcase_22 AC 9 ms
26,276 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 9 ms
26,280 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 18 APR 2024 04:20:22 PM):

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

ソースコード

diff #

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 obj
      (princ obj stream)
      (terpri stream))))

(defun ok (xs)
  (sb-int:named-let rec ((xs xs)
                         (c #\a))
    (or (null xs)
        (and (char<= c (first xs))
             (rec (rest xs)
                  (first xs))))))

(defun get-l-and-r (xs)
  (when (ok xs)
    (list (length xs)
          (first (sort (copy-seq xs) #'char<))
          (first (sort (copy-seq xs) #'char>)))))

(define-modify-macro maxf (var) max)

(defun char->int (c)
  (- (char-code c)
     (char-code #\a)))

(defun main ()
  (let* ((n (read))
         (ss (sort (remove-if #'null (mapcar #'get-l-and-r (loop repeat n collect (concatenate 'list (read-line))))) #'(lambda (xs ys)
                                                                                                                         (if (char= (second xs) (second ys))
                                                                                                                             (char< (third xs) (third ys))
                                                                                                                             (char< (second xs) (second ys))))))
         (ys (make-array 26 :initial-element nil)))
    (loop for (cnt l r) in ss
          do (push (list cnt (char->int r))
                   (aref ys (char->int l))))
    (let ((dp (make-array 26)))
      (dotimes (l 26)
        (let ((tmp (make-array 26)))
          (loop for (cnt r) in (aref ys l)
                do (loop for idx from r below 26
                         do (maxf (aref tmp idx)
                                  (+ (aref dp l)
                                     cnt))))
          (setf dp tmp)))
      (println (reduce #'max dp)))))

#-swank (main)
0