結果

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

テストケース

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

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

ソースコード

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)
  (princ (eat-bean (* (car *num-list*) (cadr *num-list*))
		   *age-list*))
  )

(n143)

0