結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2018-09-17 15:03:59 |
言語 | Scheme (Gauche-0.9.15) |
結果 |
AC
|
実行時間 | 29 ms / 5,000 ms |
コード長 | 567 bytes |
コンパイル時間 | 159 ms |
コンパイル使用メモリ | 6,948 KB |
実行使用メモリ | 16,256 KB |
最終ジャッジ日時 | 2024-12-27 19:27:49 |
合計ジャッジ時間 | 2,210 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
(define n (string->number (read-line))) (define v (list->vector(map string->number (string-split (read-line) " ")))) (define (calc-max i a1 a2) (let1 m (max a1 (+ (vector-ref v (+ (- n i) 2)) a2)) (if (= i 3) m (calc-max (- i 1) m a1)))) (define v0 (vector-ref v 0)) (print (cond ((= n 1) v0) ((= n 2) (max v0 (vector-ref v 1))) (else (calc-max n (max v0 (vector-ref v 1)) v0))))