結果

問題 No.338 アンケート機能
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-03-14 00:44:28
言語 Scheme
(Gauche-0.9.14)
結果
AC  
実行時間 154 ms / 2,000 ms
コード長 1,006 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 6,816 KB
実行使用メモリ 25,728 KB
最終ジャッジ日時 2024-04-25 15:57:25
合計ジャッジ時間 6,738 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 150 ms
25,472 KB
testcase_01 AC 148 ms
25,472 KB
testcase_02 AC 150 ms
25,472 KB
testcase_03 AC 145 ms
25,472 KB
testcase_04 AC 147 ms
25,472 KB
testcase_05 AC 151 ms
25,472 KB
testcase_06 AC 147 ms
25,472 KB
testcase_07 AC 143 ms
25,452 KB
testcase_08 AC 148 ms
25,600 KB
testcase_09 AC 145 ms
25,600 KB
testcase_10 AC 152 ms
25,472 KB
testcase_11 AC 149 ms
25,472 KB
testcase_12 AC 145 ms
25,600 KB
testcase_13 AC 149 ms
25,728 KB
testcase_14 AC 148 ms
25,600 KB
testcase_15 AC 144 ms
25,512 KB
testcase_16 AC 146 ms
25,728 KB
testcase_17 AC 151 ms
25,472 KB
testcase_18 AC 151 ms
25,472 KB
testcase_19 AC 145 ms
25,472 KB
testcase_20 AC 150 ms
25,600 KB
testcase_21 AC 147 ms
25,580 KB
testcase_22 AC 145 ms
25,600 KB
testcase_23 AC 152 ms
25,472 KB
testcase_24 AC 148 ms
25,472 KB
testcase_25 AC 144 ms
25,472 KB
testcase_26 AC 148 ms
25,600 KB
testcase_27 AC 147 ms
25,472 KB
testcase_28 AC 148 ms
25,472 KB
testcase_29 AC 154 ms
25,472 KB
testcase_30 AC 147 ms
25,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

(use srfi-42) ;; 内包表記の使用に必要
(define max-a-b 300) ;; 検索対象とするa, bの上限
;; 四捨五入の関数
(define (round-up-on-5 x) (truncate->exact (+ x (/ 1 2))))
(define (comp-min-a+b a0 b0)
    (min-ec ;;内包表記。以下の計算の結果のうちで、最小のものを返す
        (: a 0 max-a-b) ;;aを[0, max-a-b)で動かす
        (: b 0 max-a-b) ;;bを[0, max-a-b)で動かす
        (let
            ((s (+ a b)))
            (if
                (and
                    (not (and (= a 0) (= b 0)))
                    (= a0 (round-up-on-5 (/ (* 100 a) s)))
                    (= b0 (round-up-on-5 (/ (* 100 b) s)))
                )
                s ;; 条件に合えば最小値の候補に入れる
                1000 ;; 条件が満たされなければ適当な大きい数を返す
            )
        )
    )
)

(let*
    ((a0 (read)) (b0 (read))) ;;A, Bを読み取る
    (print (comp-min-a+b a0 b0)) ;;計算結果を表示し改行する
)
0