結果

問題 No.115 遠足のおやつ
ユーザー titia
提出日時 2022-02-07 01:41:25
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 32 ms / 5,000 ms
コード長 440 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-06-11 14:36:15
合計ジャッジ時間 3,021 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

N,D,K=map(int,input().split())

def calc(l,r,K):
    return (l+(l+K-1))*K//2,(r+(r-K+1))*K//2

ANS=[0]

for tests in range(K):
    SUM=sum(ANS)

    for j in range(ANS[-1]+1,N+1):
        if N-(j+1)+1<K-len(ANS):
            continue

        MIN,MAX=calc(j+1,N,K-len(ANS))

        if MIN<=D-(SUM+j)<=MAX:
            ANS.append(j)
            break

if len(ANS)==K+1 and sum(ANS)==D:
    print(*ANS[1:])
else:
    print(-1)
        
    
0