結果

問題 No.45 回転寿司
ユーザー _Clay____
提出日時 2018-09-17 13:38:31
言語 Scheme
(Gauche-0.9.15)
結果
WA  
実行時間 -
コード長 972 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 5,120 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2024-07-18 07:38:32
合計ジャッジ時間 1,949 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

(let* ((n (string->number (read-line)))
       (v (list->vector(map string->number (string-split (read-line) " ")))))
      (letrec ((calc-max 
                   (lambda (i a1 a2)
                     (cond
                       ((eq? i 3) (max
                                    a1 
                                    (+ (vector-ref v (- i 1)) a2))) 
                       (else (calc-max 
                                (- i 1)
                                (max
                                  a1 
                                  (+ (vector-ref v (- i 1)) a2))
                                a1))))))
              (print (cond ((eq? n 1) (vector-ref v 0))
                           ((eq? n 2) (max (vector-ref v 0) (vector-ref v 1)))
                            (else 
                              (calc-max n 
                                        (vector-ref v 0)
                                        (max (vector-ref v 0) (vector-ref v 1))))))))
0