結果

問題 No.115 遠足のおやつ
ユーザー Konton7Konton7
提出日時 2019-05-01 22:56:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 653 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 10,880 KB
実行使用メモリ 7,888 KB
最終ジャッジ日時 2023-08-30 04:28:43
合計ジャッジ時間 3,347 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 16 ms
7,768 KB
testcase_06 WA -
testcase_07 AC 16 ms
7,772 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 16 ms
7,884 KB
testcase_18 WA -
testcase_19 AC 16 ms
7,752 KB
testcase_20 WA -
testcase_21 AC 16 ms
7,816 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 17 ms
7,752 KB
testcase_26 AC 17 ms
7,816 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 17 ms
7,748 KB
testcase_30 WA -
testcase_31 AC 16 ms
7,828 KB
testcase_32 WA -
testcase_33 AC 16 ms
7,824 KB
testcase_34 WA -
testcase_35 AC 16 ms
7,820 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

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