結果

問題 No.115 遠足のおやつ
ユーザー maimai
提出日時 2017-04-13 20:59:17
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,089 ms / 5,000 ms
コード長 453 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 11,576 KB
実行使用メモリ 33,872 KB
最終ジャッジ日時 2023-08-31 00:43:57
合計ジャッジ時間 9,241 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 149 ms
33,548 KB
testcase_01 AC 150 ms
33,760 KB
testcase_02 AC 148 ms
33,640 KB
testcase_03 AC 148 ms
33,780 KB
testcase_04 AC 150 ms
33,704 KB
testcase_05 AC 149 ms
33,644 KB
testcase_06 AC 148 ms
33,544 KB
testcase_07 AC 150 ms
33,680 KB
testcase_08 AC 151 ms
33,780 KB
testcase_09 AC 150 ms
33,556 KB
testcase_10 AC 150 ms
33,604 KB
testcase_11 AC 151 ms
33,700 KB
testcase_12 AC 150 ms
33,748 KB
testcase_13 AC 152 ms
33,604 KB
testcase_14 AC 150 ms
33,644 KB
testcase_15 AC 151 ms
33,560 KB
testcase_16 AC 151 ms
33,872 KB
testcase_17 AC 152 ms
33,704 KB
testcase_18 AC 151 ms
33,760 KB
testcase_19 AC 148 ms
33,648 KB
testcase_20 AC 151 ms
33,816 KB
testcase_21 AC 148 ms
33,644 KB
testcase_22 AC 149 ms
33,860 KB
testcase_23 AC 151 ms
33,608 KB
testcase_24 AC 154 ms
33,484 KB
testcase_25 AC 154 ms
33,564 KB
testcase_26 AC 149 ms
33,648 KB
testcase_27 AC 150 ms
33,660 KB
testcase_28 AC 151 ms
33,808 KB
testcase_29 AC 157 ms
33,868 KB
testcase_30 AC 151 ms
33,820 KB
testcase_31 AC 149 ms
33,860 KB
testcase_32 AC 151 ms
33,828 KB
testcase_33 AC 151 ms
33,772 KB
testcase_34 AC 152 ms
33,656 KB
testcase_35 AC 155 ms
33,868 KB
testcase_36 AC 150 ms
33,608 KB
testcase_37 AC 149 ms
33,812 KB
testcase_38 AC 147 ms
33,548 KB
testcase_39 AC 1,089 ms
33,692 KB
testcase_40 AC 151 ms
33,692 KB
testcase_41 AC 151 ms
33,628 KB
testcase_42 AC 151 ms
33,812 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def scan; gets.split.map(&:to_i); end

n,d,k = scan

@memo=Array.new(101){Array.new(1111){Array.new(11)}}
def dfs(n,d,k)
    return d == 0 if k == 0
    return false if d <= 0
    return false if n <= 0
    
    return false if @memo[n][d][k]
    
    n.downto(1){|coin|
        if dfs(coin-1,d-coin,k-1)
            printf "%d ",coin
            return true
        end
    }
    @memo[n][d][k] = true
    return false
end

puts "-1" unless dfs(n,d,k)
0