結果

問題 No.279 木の数え上げ
ユーザー yusakayusaka
提出日時 2015-09-22 04:24:32
言語 Scheme
(Gauche-0.9.14)
結果
AC  
実行時間 330 ms / 2,000 ms
コード長 1,055 bytes
コンパイル時間 44 ms
コンパイル使用メモリ 6,688 KB
実行使用メモリ 34,688 KB
最終ジャッジ日時 2024-04-22 16:05:39
合計ジャッジ時間 4,682 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
17,280 KB
testcase_01 AC 31 ms
17,024 KB
testcase_02 AC 31 ms
16,896 KB
testcase_03 AC 31 ms
17,024 KB
testcase_04 AC 31 ms
17,024 KB
testcase_05 AC 32 ms
17,024 KB
testcase_06 AC 31 ms
17,152 KB
testcase_07 AC 30 ms
17,152 KB
testcase_08 AC 31 ms
17,024 KB
testcase_09 AC 29 ms
17,024 KB
testcase_10 AC 315 ms
33,408 KB
testcase_11 AC 97 ms
20,096 KB
testcase_12 AC 224 ms
27,904 KB
testcase_13 AC 68 ms
18,432 KB
testcase_14 AC 330 ms
34,688 KB
testcase_15 AC 293 ms
31,360 KB
testcase_16 AC 270 ms
29,952 KB
testcase_17 AC 314 ms
33,408 KB
testcase_18 AC 180 ms
25,216 KB
testcase_19 AC 313 ms
32,768 KB
testcase_20 AC 321 ms
33,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env gosh
(define (hoge)
  (let ((input (read-line)))
    (display (count-tree input))
    (newline)))

(define (count-tree str)
  (let ((char-list (string->list str))
        (count-char-lambdas (list (count-char #\t)
                                  (count-char #\r)
                                  (div2 (count-char #\e)))))
    (define (apply-lambdas lst arg)
      (if (equal? '() lst)
          lst
          (cons ((car lst) arg) (apply-lambdas (cdr lst) arg))))
    (minimum (apply-lambdas count-char-lambdas char-list))))

(define (minimum lst)
  (define (iter lst holder)
    (if (null? lst)
        holder
        (if (< holder (car lst))
            (iter (cdr lst) holder)
            (iter (cdr lst) (car lst)))))
  (iter (cdr lst) (car lst)))

(define (div2 f)
  (lambda (x)
    (div (f x) 2)))

(define (count-char char)
  (lambda (x)
    (define (iter x i)
      (if (equal? x '())
          i
          (if (equal? (car x) char)
              (iter (cdr x) (+ i 1))
              (iter (cdr x) i))))
    (iter x 0)))
(hoge)
0