結果

問題 No.365 ジェンガソート
ユーザー ikd
提出日時 2019-08-05 10:08:42
言語 Scheme
(Gauche-0.9.15)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 440 bytes
コンパイル時間 49 ms
コンパイル使用メモリ 6,944 KB
実行使用メモリ 20,864 KB
最終ジャッジ日時 2024-07-18 13:07:40
合計ジャッジ時間 3,283 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#! /usr/bin/env gosh

(let* ([n (read)]
      [a (let input ([i 0] [li (list)])
           (if (= i n)
             li
             (input (+ i 1) (cons (read) li))))])
  (let ([cost (let solve ([i 0] [li a] [tgt n] [res 0])
    (if (= i n)
      res
      (let* ([found (= (car li) tgt)])
        (solve (+ i 1)
               (cdr li)
               (- tgt (if found 1 0))
               (+ res (if found 0 1))))))])
    (display cost)))
0