結果

問題 No.115 遠足のおやつ
ユーザー maimai
提出日時 2017-04-13 21:01:54
言語 Ruby
(3.3.0)
結果
AC  
実行時間 676 ms / 5,000 ms
コード長 444 bytes
コンパイル時間 226 ms
コンパイル使用メモリ 11,348 KB
実行使用メモリ 25,152 KB
最終ジャッジ日時 2023-08-31 00:44:03
合計ジャッジ時間 6,371 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
24,812 KB
testcase_01 AC 92 ms
24,976 KB
testcase_02 AC 89 ms
24,884 KB
testcase_03 AC 94 ms
25,088 KB
testcase_04 AC 93 ms
25,028 KB
testcase_05 AC 91 ms
24,916 KB
testcase_06 AC 92 ms
24,840 KB
testcase_07 AC 93 ms
24,840 KB
testcase_08 AC 95 ms
24,884 KB
testcase_09 AC 95 ms
24,948 KB
testcase_10 AC 93 ms
24,932 KB
testcase_11 AC 94 ms
24,792 KB
testcase_12 AC 94 ms
25,056 KB
testcase_13 AC 95 ms
24,932 KB
testcase_14 AC 94 ms
24,908 KB
testcase_15 AC 94 ms
24,912 KB
testcase_16 AC 95 ms
24,936 KB
testcase_17 AC 96 ms
25,060 KB
testcase_18 AC 94 ms
24,868 KB
testcase_19 AC 94 ms
25,152 KB
testcase_20 AC 94 ms
24,916 KB
testcase_21 AC 93 ms
24,900 KB
testcase_22 AC 94 ms
24,788 KB
testcase_23 AC 96 ms
24,788 KB
testcase_24 AC 92 ms
24,920 KB
testcase_25 AC 96 ms
24,852 KB
testcase_26 AC 91 ms
25,064 KB
testcase_27 AC 93 ms
25,092 KB
testcase_28 AC 91 ms
24,952 KB
testcase_29 AC 90 ms
25,024 KB
testcase_30 AC 91 ms
24,904 KB
testcase_31 AC 92 ms
24,912 KB
testcase_32 AC 92 ms
24,904 KB
testcase_33 AC 93 ms
24,904 KB
testcase_34 AC 94 ms
25,104 KB
testcase_35 AC 93 ms
24,796 KB
testcase_36 AC 89 ms
25,056 KB
testcase_37 AC 93 ms
25,008 KB
testcase_38 AC 94 ms
24,944 KB
testcase_39 AC 676 ms
24,908 KB
testcase_40 AC 92 ms
24,932 KB
testcase_41 AC 92 ms
25,108 KB
testcase_42 AC 92 ms
24,916 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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

n,d,k = scan

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

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