結果

問題 No.143 豆
ユーザー mikan-watermikan-water
提出日時 2024-01-14 10:37:44
言語 Common Lisp
(sbcl 2.3.8)
結果
WA  
実行時間 -
コード長 1,344 bytes
コンパイル時間 1,522 ms
コンパイル使用メモリ 37,072 KB
実行使用メモリ 29,344 KB
最終ジャッジ日時 2024-01-14 10:37:47
合計ジャッジ時間 2,951 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 14 JAN 2024 01:37:44 AM):

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

ソースコード

diff #

; variables

; k: the number of beans in a pack
; n: the number of packs
; f: the number of family members
; (k n f)
(defparameter *bean-pack-family* ())
(defparameter *input-str* nil)
(defparameter *num-list* ())
(defparameter *age-list* ())
(defvar *num-stack* ())
(defvar *list-stack* ())


; function

(defun separate-n (c)
  (cond
    ((char= c #\ )
     (push (parse-integer (coerce (reverse *num-stack*) 'string)) *list-stack*)
     (setf *num-stack* '())
     )
    (t
      (push c *num-stack*)))
  )

(defun str-to-int-list (str)
  (map nil #'separate-n str) 
  (push (parse-integer (coerce (reverse *num-stack*) 'string)) *list-stack*)
  (reverse *list-stack*)
  )

(defun input-to-list ()
  (setf *input-str* (read-line))
  (setf *num-list* (str-to-int-list *input-str*))
  (reset-stack)
  )

(defun reset-stack ()
  (setf *num-stack* ())
  (setf *list-stack* ())
  )

(defun input-to-age ()
  (setf *input-str* (read-line))
  (setf *age-list* (str-to-int-list *input-str*))
  )

(defun eat-bean (total age-list)
  (cond
    ((< total 0) -1)
    ((< (length age-list) 1)
     total)
    (t 
      (eat-bean (- total (car age-list)) (cdr age-list))))
  )

(defun n143 ()
  (input-to-list)
  (input-to-age)
;  (print (eat-bean 100 '(10 20 30)))
  (print (eat-bean (* (car *num-list*) (cadr *num-list*))
		   *age-list*))
  )

(n143)

0