結果

問題 No.45 回転寿司
ユーザー mikan-watermikan-water
提出日時 2024-01-21 11:27:16
言語 Common Lisp
(sbcl 2.3.8)
結果
RE  
実行時間 -
コード長 957 bytes
コンパイル時間 935 ms
コンパイル使用メモリ 28,160 KB
実行使用メモリ 25,600 KB
最終ジャッジ日時 2024-09-28 06:13:23
合計ジャッジ時間 1,686 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
21,632 KB
testcase_01 AC 8 ms
21,760 KB
testcase_02 AC 8 ms
21,760 KB
testcase_03 AC 8 ms
21,760 KB
testcase_04 AC 8 ms
21,760 KB
testcase_05 AC 7 ms
21,632 KB
testcase_06 AC 8 ms
21,888 KB
testcase_07 AC 8 ms
21,760 KB
testcase_08 AC 8 ms
21,760 KB
testcase_09 AC 8 ms
21,760 KB
testcase_10 AC 7 ms
21,632 KB
testcase_11 AC 7 ms
21,504 KB
testcase_12 AC 8 ms
21,760 KB
testcase_13 AC 7 ms
21,632 KB
testcase_14 AC 7 ms
21,632 KB
testcase_15 AC 8 ms
21,632 KB
testcase_16 AC 8 ms
21,632 KB
testcase_17 AC 8 ms
21,760 KB
testcase_18 AC 8 ms
21,632 KB
testcase_19 AC 8 ms
21,760 KB
testcase_20 AC 7 ms
21,632 KB
testcase_21 AC 8 ms
21,632 KB
testcase_22 AC 7 ms
21,760 KB
testcase_23 AC 8 ms
21,632 KB
testcase_24 AC 7 ms
21,632 KB
testcase_25 RE -
testcase_26 AC 8 ms
21,760 KB
testcase_27 AC 8 ms
21,888 KB
testcase_28 AC 8 ms
21,632 KB
testcase_29 AC 8 ms
21,760 KB
testcase_30 AC 7 ms
21,888 KB
testcase_31 AC 7 ms
21,760 KB
testcase_32 AC 7 ms
21,760 KB
testcase_33 AC 7 ms
21,888 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
; 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