結果

問題 No.2790 Athena 3
ユーザー Lisp_CoderLisp_Coder
提出日時 2024-06-22 17:05:25
言語 Common Lisp
(sbcl 2.3.8)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 1,037 bytes
コンパイル時間 488 ms
コンパイル使用メモリ 37,352 KB
実行使用メモリ 31,892 KB
最終ジャッジ日時 2024-06-22 17:05:26
合計ジャッジ時間 1,510 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
27,724 KB
testcase_01 AC 8 ms
25,768 KB
testcase_02 AC 8 ms
27,980 KB
testcase_03 AC 9 ms
25,900 KB
testcase_04 AC 7 ms
25,772 KB
testcase_05 AC 8 ms
27,932 KB
testcase_06 AC 7 ms
25,768 KB
testcase_07 AC 9 ms
25,636 KB
testcase_08 AC 8 ms
25,640 KB
testcase_09 AC 8 ms
25,772 KB
testcase_10 AC 9 ms
27,852 KB
testcase_11 AC 9 ms
27,856 KB
testcase_12 AC 11 ms
31,892 KB
testcase_13 AC 9 ms
25,768 KB
testcase_14 AC 9 ms
27,676 KB
testcase_15 AC 8 ms
25,892 KB
testcase_16 AC 8 ms
29,992 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 22 JUN 2024 05:05:24 PM):

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

ソースコード

diff #

(defun read-points ()
  (list (read) (read) (read) (read) (read) (read)))

(defun calculate-area (x1 y1 x2 y2 x3 y3)
  (/ (abs (- (+ (* x1 (- y2 y3)) (* x2 (- y3 y1)) (* x3 (- y1 y2))))) 2.0))

(defun max-triangle-area (points)
  (let* ((x1 (nth 0 points))
         (y1 (nth 1 points))
         (x2 (nth 2 points))
         (y2 (nth 3 points))
         (x3 (nth 4 points))
         (y3 (nth 5 points))
         (deltas '((1 0) (-1 0) (0 1) (0 -1)))
         (max-area 0.0))
    (dolist (d1 deltas)
      (dolist (d2 deltas)
        (dolist (d3 deltas)
          (let* ((new-x1 (+ x1 (car d1)))
                 (new-y1 (+ y1 (cadr d1)))
                 (new-x2 (+ x2 (car d2)))
                 (new-y2 (+ y2 (cadr d2)))
                 (new-x3 (+ x3 (car d3)))
                 (new-y3 (+ y3 (cadr d3)))
                 (area (calculate-area new-x1 new-y1 new-x2 new-y2 new-x3 new-y3)))
            (setf max-area (max max-area area))))))
    max-area))

(let ((points (read-points)))
  (format t "~f~%" (max-triangle-area points)))
0