結果

問題 No.115 遠足のおやつ
ユーザー JunOnumaJunOnuma
提出日時 2017-06-16 13:09:33
言語 Python2
(2.7.18)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 497 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2025-01-03 01:24:10
合計ジャッジ時間 1,756 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

def func(s,e,k,t):
    if s > t or (s+e)*(e-s+1)/2 < t or (e + e - k + 1) * k / 2 < t:
        return []
    if k == 1:
        if s <= t and t <= e:
            return [t]
        else:
            return []
    for i in range(s,e+1):
        l = func(i+1,e,k-1,t-i)
        if l != []:
            l.append(i)
            return l
    else:
        return []

n,d,k = map(int, raw_input().split())
l = func(1,n,k,d)
if l == []:
    print -1
else:
    l.reverse()
    print ' '.join(map(str, l))
0