結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
24,844 KB
testcase_01 AC 96 ms
24,880 KB
testcase_02 AC 95 ms
25,060 KB
testcase_03 AC 97 ms
25,060 KB
testcase_04 AC 95 ms
24,908 KB
testcase_05 AC 95 ms
24,904 KB
testcase_06 AC 97 ms
24,996 KB
testcase_07 AC 97 ms
24,904 KB
testcase_08 AC 97 ms
24,904 KB
testcase_09 AC 97 ms
25,028 KB
testcase_10 AC 96 ms
24,904 KB
testcase_11 AC 96 ms
25,064 KB
testcase_12 AC 95 ms
25,108 KB
testcase_13 AC 95 ms
24,904 KB
testcase_14 AC 97 ms
25,104 KB
testcase_15 AC 95 ms
24,936 KB
testcase_16 AC 96 ms
25,112 KB
testcase_17 AC 96 ms
25,048 KB
testcase_18 AC 96 ms
25,004 KB
testcase_19 AC 95 ms
24,932 KB
testcase_20 AC 97 ms
25,064 KB
testcase_21 AC 96 ms
25,108 KB
testcase_22 AC 97 ms
24,788 KB
testcase_23 AC 99 ms
25,112 KB
testcase_24 AC 96 ms
24,908 KB
testcase_25 AC 99 ms
24,916 KB
testcase_26 AC 97 ms
25,108 KB
testcase_27 AC 96 ms
24,936 KB
testcase_28 AC 98 ms
25,056 KB
testcase_29 AC 96 ms
25,028 KB
testcase_30 AC 95 ms
25,056 KB
testcase_31 AC 97 ms
24,884 KB
testcase_32 AC 94 ms
24,920 KB
testcase_33 AC 95 ms
25,028 KB
testcase_34 AC 96 ms
24,908 KB
testcase_35 AC 98 ms
24,912 KB
testcase_36 AC 97 ms
25,056 KB
testcase_37 AC 97 ms
25,032 KB
testcase_38 AC 97 ms
24,916 KB
testcase_39 AC 816 ms
24,788 KB
testcase_40 AC 96 ms
24,856 KB
testcase_41 AC 96 ms
24,904 KB
testcase_42 AC 96 ms
24,920 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
    
    return false if @memo[k][n][d]
    
    n.downto(1){|coin|
        if 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