結果

問題 No.115 遠足のおやつ
ユーザー Konton7
提出日時 2019-05-01 22:58:01
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 658 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-12-31 12:42:27
合計ジャッジ時間 2,680 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

n, d, k = [ int(v) for v in input().split(" ") ]

moneylist = [i+1 for i in range(n)]

def uppersum(inlist,a):
    return sum(inlist[-a:])
def lowersum(inlist,a):
    return sum(inlist[:a])

ans = -1
anslist = []
if lowersum(moneylist,k) <= d <= uppersum(moneylist,k):
    lowest = 1
    for i in range(1,k):
        for j in range(lowest,n):
            if d - j <= uppersum(moneylist,k-i):
                lowest = j + 1
                moneylist = moneylist[lowest+1:]
                anslist.append(j)
                d = d - j
                break
    anslist.append(d)

    ans = " ".join([ str(anslist[i]) for i in range(len(anslist)) ]) 
print(ans)
0