結果

問題 No.115 遠足のおやつ
コンテスト
ユーザー JunOnuma
提出日時 2017-06-16 13:09:33
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 88 ms / 5,000 ms
コード長 497 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 291 ms
コンパイル使用メモリ 77,592 KB
最終ジャッジ日時 2025-12-04 00:10:29
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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