結果

問題 No.45 回転寿司
ユーザー mikan-water
提出日時 2024-01-21 11:27:16
言語 Common Lisp
(sbcl 2.5.0)
結果
RE  
実行時間 -
コード長 957 bytes
コンパイル時間 935 ms
コンパイル使用メモリ 28,160 KB
実行使用メモリ 25,600 KB
最終ジャッジ日時 2024-09-28 06:13:23
合計ジャッジ時間 1,686 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 RE * 1
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 28 SEP 2024 06:13:20 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.041

ソースコード

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 (max (car *v*) (cadr *v*)) *dp*)

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

(n45)
0