結果

問題 No.115 遠足のおやつ
ユーザー finefine
提出日時 2016-03-15 16:27:48
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 545 bytes
コンパイル時間 47 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 22,932 KB
最終ジャッジ日時 2024-04-08 13:21:36
合計ジャッジ時間 10,843 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
16,256 KB
testcase_01 AC 90 ms
16,256 KB
testcase_02 AC 97 ms
16,256 KB
testcase_03 AC 93 ms
16,256 KB
testcase_04 AC 911 ms
16,256 KB
testcase_05 AC 92 ms
16,256 KB
testcase_06 AC 90 ms
16,256 KB
testcase_07 AC 91 ms
16,256 KB
testcase_08 AC 90 ms
16,256 KB
testcase_09 AC 88 ms
16,256 KB
testcase_10 AC 89 ms
16,256 KB
testcase_11 AC 90 ms
16,256 KB
testcase_12 AC 92 ms
16,256 KB
testcase_13 AC 93 ms
16,256 KB
testcase_14 AC 91 ms
16,256 KB
testcase_15 AC 440 ms
16,256 KB
testcase_16 AC 131 ms
16,256 KB
testcase_17 AC 92 ms
16,256 KB
testcase_18 AC 92 ms
16,256 KB
testcase_19 AC 93 ms
16,256 KB
testcase_20 AC 91 ms
16,256 KB
testcase_21 AC 92 ms
16,256 KB
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:22: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Main.rb:28: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

def sol s,e,a,k,d
    if k == 0
        if a.inject(:+) == d
            return a
        else
            return nil
        end
    else
        s.upto(e){|i|
            a.push(i)
            tmp = sol(i + 1,e,a,k - 1,d)
            if tmp
                return tmp
            end
            a.pop
            }
        return nil
    end
end
n,d,k = gets.split.map(&:to_i)
if d < k * (k + 1) / 2 || d > (n * 2 - k + 1) * k / 2
    p -1
else
    tmp = sol(1,n,[],k,d)
    if tmp
        puts tmp.join(' ')
    else
        p -1
    end
end
0