結果

問題 No.115 遠足のおやつ
ユーザー zyxw
提出日時 2020-12-14 07:49:36
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 38 ms / 5,000 ms
コード長 447 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 12,032 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2025-01-03 02:00:58
合計ジャッジ時間 3,184 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

N,D,K=map(int,input().split())
if N>=K and K*(K+1)//2<=D<=N*(N+1)//2-(N-K)*(N-K+1)//2:
    data=[0]
    S=0
    L=0
    for i in range(K):
        if i==K-1:
            data.append(D-S)
            continue
        for j in range(data[-1]+1,N+1):
            if D-S-j<=N*(N+1)//2-(N-(K-L)+1)*(N-(K-L)+2)//2:
                data.append(j)
                S+=j
                L+=1
                break
    print(*data[1:K+1])
else:
    print(-1)
0