結果

問題 No.115 遠足のおやつ
ユーザー mkawa2
提出日時 2019-12-24 14:42:00
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 34 ms / 5,000 ms
コード長 771 bytes
コンパイル時間 250 ms
コンパイル使用メモリ 12,160 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2025-01-03 01:50:16
合計ジャッジ時間 3,085 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n,d,k=MI()
    if d<k*(k+1)//2 or d>(2*n-k+1)*k//2:
        print(-1)
        exit()
    ans=list(range(1,k+1))
    s=sum(ans)
    d-=s
    for i in range(k-1,-1,-1):
        diff=min(d,n-k)
        ans[i]+=diff
        d-=diff
        if d==0:break
    print(*ans)

main()
0