結果
| 問題 | No.17 2つの地点に泊まりたい | 
| コンテスト | |
| ユーザー |  Common Lisp | 
| 提出日時 | 2024-11-08 23:25:20 | 
| 言語 | Common Lisp (sbcl 2.5.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 16 ms / 5,000 ms | 
| コード長 | 1,148 bytes | 
| コンパイル時間 | 1,449 ms | 
| コンパイル使用メモリ | 39,936 KB | 
| 実行使用メモリ | 24,320 KB | 
| 最終ジャッジ日時 | 2024-11-08 23:25:24 | 
| 合計ジャッジ時間 | 2,673 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 27 | 
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 08 NOV 2024 11:25:21 PM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.209
ソースコード
(defconstant +inf+ 9876543218987654321)
(defun main (&rest argv)
  (declare (ignorable argv))
  (let* ((n (read))
         (s (make-array n :element-type 'integer)))
    (dotimes (i n) (setf (aref s i) (read)))
    (let* ((m (read))
           (d (make-array (list n n) :element-type 'integer :initial-element +inf+))
           (res +inf+))
      (dotimes (i n) (setf (aref d i i) 0))
      (dotimes (i m)
        (let* ((a (read))
               (b (read))
               (c (read)))
          (setf (aref d a b) c
                (aref d b a) c)))
      (dotimes (i n)
        (dotimes (j n)
          (dotimes (k n)
            (setf (aref d j k)
                  (min (aref d j k)
                       (+ (aref d j i)
                          (aref d i k)))))))
      (loop for i from 1 below (1- n) do
            (loop for j from 1 below (1- n) do
                  (unless (= i j)
                          (setq res (min res (+ (aref d 0 i)
                                                (aref s i) (aref d i j)
                                                (aref s j) (aref d j (1- n))))))))
      (format t "~d~%" res))))
(main)
            
            
            
        