結果
問題 | No.535 自然数の収納方法 |
ユーザー | Common Lisp |
提出日時 | 2024-11-13 18:40:06 |
言語 | Common Lisp (sbcl 2.3.8) |
結果 |
AC
|
実行時間 | 442 ms / 2,000 ms |
コード長 | 1,230 bytes |
コンパイル時間 | 272 ms |
コンパイル使用メモリ | 49,788 KB |
実行使用メモリ | 94,620 KB |
最終ジャッジ日時 | 2024-11-13 18:40:12 |
合計ジャッジ時間 | 6,200 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 24 ms
61,784 KB |
testcase_01 | AC | 23 ms
63,820 KB |
testcase_02 | AC | 32 ms
61,916 KB |
testcase_03 | AC | 23 ms
61,788 KB |
testcase_04 | AC | 25 ms
63,948 KB |
testcase_05 | AC | 24 ms
63,820 KB |
testcase_06 | AC | 24 ms
61,912 KB |
testcase_07 | AC | 94 ms
73,948 KB |
testcase_08 | AC | 251 ms
86,220 KB |
testcase_09 | AC | 310 ms
88,540 KB |
testcase_10 | AC | 364 ms
90,456 KB |
testcase_11 | AC | 61 ms
69,976 KB |
testcase_12 | AC | 171 ms
78,296 KB |
testcase_13 | AC | 25 ms
63,948 KB |
testcase_14 | AC | 127 ms
80,288 KB |
testcase_15 | AC | 384 ms
92,624 KB |
testcase_16 | AC | 249 ms
86,352 KB |
testcase_17 | AC | 406 ms
94,620 KB |
testcase_18 | AC | 23 ms
61,784 KB |
testcase_19 | AC | 412 ms
90,440 KB |
testcase_20 | AC | 415 ms
94,488 KB |
testcase_21 | AC | 442 ms
90,444 KB |
testcase_22 | AC | 414 ms
92,456 KB |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 13 NOV 2024 06:40:06 PM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.072
ソースコード
(defun main (&rest argv) (declare (ignorable argv)) (let* ((dp1 (make-array (list 2002 2002) :element-type 'integer :initial-element 0)) (dp2 (make-array (list 2002 2002) :element-type 'integer :initial-element 0)) (n (read)) (res 0)) (loop for i from 1 to n do (setf (aref dp1 0 i) 1)) (loop for i from 1 below n do (setf (aref dp2 (1- i) 0) 0) (loop for j from 1 to n do (setf (aref dp2 (1- i) j) (mod (+ (aref dp2 (1- i) (1- j)) (aref dp1 (1- i) j)) 1000000007))) (loop for j from 1 to n do (setf (aref dp1 i j) (mod (aref dp2 (1- i) (min n (+ j -1 (max 1 (1- i))))) 1000000007)))) (loop for i from 1 to n do (incf res (aref dp1 (1- n) i))) (dotimes (i 2002) (dotimes (j 2002) (setf (aref dp1 i j) 0))) (setf (aref dp1 0 1) 1) (loop for i from 1 below n do (setf (aref dp2 (1- i) 0) 0) (loop for j from 1 to n do (setf (aref dp2 (1- i) j) (mod (+ (aref dp2 (1- i) (1- j)) (aref dp1 (1- i) j)) 1000000007))) (loop for j from 1 to n do (setf (aref dp1 i j) (mod (aref dp2 (1- i) (min n (+ j -1 (max 1 (1- i))))) 1000000007)))) (decf res (aref dp1 (1- n) n)) (format t "~d~%" (mod res 1000000007)))) (main)