結果

問題 No.45 回転寿司
ユーザー mikan-watermikan-water
提出日時 2024-01-21 11:28:52
言語 Common Lisp
(sbcl 2.3.8)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 960 bytes
コンパイル時間 1,390 ms
コンパイル使用メモリ 37,340 KB
実行使用メモリ 29,472 KB
最終ジャッジ日時 2024-01-21 11:28:59
合計ジャッジ時間 1,817 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
29,472 KB
testcase_01 AC 9 ms
29,472 KB
testcase_02 AC 9 ms
29,472 KB
testcase_03 AC 9 ms
29,472 KB
testcase_04 AC 9 ms
29,472 KB
testcase_05 AC 9 ms
29,344 KB
testcase_06 AC 9 ms
29,472 KB
testcase_07 AC 9 ms
29,472 KB
testcase_08 AC 9 ms
29,344 KB
testcase_09 AC 10 ms
29,472 KB
testcase_10 AC 9 ms
29,472 KB
testcase_11 AC 9 ms
29,344 KB
testcase_12 AC 9 ms
29,472 KB
testcase_13 AC 8 ms
29,344 KB
testcase_14 AC 8 ms
29,344 KB
testcase_15 AC 9 ms
29,472 KB
testcase_16 AC 9 ms
29,472 KB
testcase_17 AC 8 ms
29,472 KB
testcase_18 AC 8 ms
29,472 KB
testcase_19 AC 10 ms
29,472 KB
testcase_20 AC 9 ms
29,344 KB
testcase_21 AC 9 ms
29,344 KB
testcase_22 AC 8 ms
29,344 KB
testcase_23 AC 9 ms
29,344 KB
testcase_24 AC 8 ms
29,344 KB
testcase_25 AC 9 ms
29,344 KB
testcase_26 AC 9 ms
29,472 KB
testcase_27 AC 9 ms
29,472 KB
testcase_28 AC 9 ms
29,472 KB
testcase_29 AC 10 ms
29,472 KB
testcase_30 AC 9 ms
29,472 KB
testcase_31 AC 9 ms
29,344 KB
testcase_32 AC 9 ms
29,344 KB
testcase_33 AC 9 ms
29,472 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 21 JAN 2024 02:28:52 AM):

; file: /home/judge/data/code/Main.lisp
; in: DEFUN INPUT-V
;     (REVERSE INT-LIST)
; 
; caught WARNING:
;   undefined variable: COMMON-LISP-USER::INT-LIST

;     (SETF INT-LIST 'NIL)
; 
; caught WARNING:
;   undefined variable: COMMON-LISP-USER::INT-LIST

; in: DEFUN SEND-INT
;     (PUSH (PARSE-INTEGER (COERCE (REVERSE N-STACK) 'STRING)) INT-LIST)
; ==>
;   (SETQ INT-LIST (CONS #:ITEM INT-LIST))
; 
; caught WARNING:
;   undefined variable: COMMON-LISP-USER::INT-LIST

; in: DEFUN INPUT-V
;     (SETF N-STACK 'NIL)
; 
; caught WARNING:
;   undefined variable: COMMON-LISP-USER::N-STACK

; in: DEFUN SEND-INT
;     (SETF N-STACK NIL)
; 
; caught WARNING:
;   undefined variable: COMMON-LISP-USER::N-STACK

;     (REVERSE N-STACK)
; 
; caught WARNING:
;   undefined variable: COMMON-LISP-USER::N-STACK

; 
; caught WARNING:
;   2 more uses of undefined variable N-STACK
; 
; compilation unit finished
;   Undefined variables:
;     INT-LIST N-STACK
;   caught 7 WARNING conditions

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

ソースコード

diff #

; variables
(defun *eat-flag* nil)
(defparameter *dp* '())

(defparameter *n* 4)
(defparameter *v* '(5 4 4 9))

; functions
(defun send-int ()
  (push (parse-integer (coerce (reverse n-stack)
			       'string))
	int-list)
  (setf n-stack nil)
  )

(defun input-v (str)
  (setf n-stack '())
  (setf int-list '())
  (loop for c across str
	do
	(cond
	  ((char= c #\ )
	   (send-int)
	   )
	  (t
	    (push c n-stack)))
	finally (send-int))
  (reverse int-list)
  )

(defun input ()
  (setf *n* (read-line))
  (setf *v* (input-v (read-line)))
  )

(defun my-max (a b)
  (cond
    ((equal a nil) b)
    ((equal b nil) a)
    (t (max a b)))
  )

(defun dp-loop (l)
  (cond
    ((equal l nil) nil)
    (t
      (push (my-max (car *dp*)
		    (+ (cadr *dp*) (car l)))
	    *dp*)
      (dp-loop (cdr l)))
      )
  )

(defun n45 ()
  (input)

  (push (car *v*) *dp*)
  (push (my-max (car *v*) (cadr *v*)) *dp*)

  (dp-loop (cddr *v*))
  (princ (car *dp*))
  )

(n45)
0