結果

問題 No.45 回転寿司
ユーザー _Clay____
提出日時 2018-09-17 14:32:54
言語 Scheme
(Gauche-0.9.15)
結果
AC  
実行時間 36 ms / 5,000 ms
コード長 993 bytes
コンパイル時間 129 ms
コンパイル使用メモリ 5,120 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2024-12-27 19:28:01
合計ジャッジ時間 2,814 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

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 (+ (- n i) 2)) a2)))
                       (else (calc-max 
                                (- i 1)
                                (max
                                  a1 
                                  (+ (vector-ref v (+ (- n i) 2)) 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 
                                        (max (vector-ref v 0) (vector-ref v 1))        
                                        (vector-ref v 0)))))))

0