結果

問題 No.45 回転寿司
ユーザー _Clay____
提出日時 2018-09-15 23:04:57
言語 Scheme
(Gauche-0.9.15)
結果
RE  
実行時間 -
コード長 920 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 6,940 KB
実行使用メモリ 16,384 KB
最終ジャッジ日時 2024-07-18 07:17:09
合計ジャッジ時間 2,461 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

(let* ((n (string->number (read-line)))
       (v (list->vector(map string->number (string-split (read-line) " "))))
       (c (make-vector 1000 -1)))
      (letrec ((calc-max 
                   (lambda (i)
                     (if (< 0 (vector-ref c i)) 
                      (vector-ref c i)
                      (cond
                        ((eq? i 1) (let ((e (vector-ref v 0))) (vector-set! c i e) e))
                        ((eq? i 2) (let ((e (max (vector-ref v 0) (vector-ref v 1)))) (vector-set! c i e) e))                       
                        (else (let ((e (max
                                          (calc-max (- i 1)) 
                                          (+ (vector-ref v (- i 1))
                                            (calc-max (- i 2))))))
                                   (vector-set! c i e)
                                   e)))))))
              (print (calc-max n))))
0