結果

問題 No.115 遠足のおやつ
ユーザー neko_the_shadowneko_the_shadow
提出日時 2019-08-05 13:36:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 61 ms / 5,000 ms
コード長 603 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 86,580 KB
実行使用メモリ 71,308 KB
最終ジャッジ日時 2023-08-31 00:53:25
合計ジャッジ時間 4,123 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
70,948 KB
testcase_01 AC 57 ms
71,112 KB
testcase_02 AC 60 ms
71,068 KB
testcase_03 AC 57 ms
70,836 KB
testcase_04 AC 60 ms
71,012 KB
testcase_05 AC 58 ms
70,800 KB
testcase_06 AC 61 ms
70,844 KB
testcase_07 AC 57 ms
71,200 KB
testcase_08 AC 59 ms
71,112 KB
testcase_09 AC 59 ms
70,708 KB
testcase_10 AC 58 ms
71,308 KB
testcase_11 AC 59 ms
70,800 KB
testcase_12 AC 60 ms
70,972 KB
testcase_13 AC 61 ms
71,032 KB
testcase_14 AC 60 ms
71,180 KB
testcase_15 AC 60 ms
71,188 KB
testcase_16 AC 60 ms
71,100 KB
testcase_17 AC 60 ms
71,068 KB
testcase_18 AC 59 ms
71,144 KB
testcase_19 AC 59 ms
71,220 KB
testcase_20 AC 60 ms
70,996 KB
testcase_21 AC 59 ms
71,204 KB
testcase_22 AC 61 ms
71,012 KB
testcase_23 AC 57 ms
71,068 KB
testcase_24 AC 59 ms
71,208 KB
testcase_25 AC 59 ms
71,108 KB
testcase_26 AC 58 ms
71,028 KB
testcase_27 AC 59 ms
71,188 KB
testcase_28 AC 57 ms
71,096 KB
testcase_29 AC 60 ms
70,968 KB
testcase_30 AC 59 ms
71,220 KB
testcase_31 AC 59 ms
71,008 KB
testcase_32 AC 58 ms
71,012 KB
testcase_33 AC 61 ms
71,040 KB
testcase_34 AC 59 ms
70,992 KB
testcase_35 AC 59 ms
71,116 KB
testcase_36 AC 59 ms
70,712 KB
testcase_37 AC 58 ms
70,668 KB
testcase_38 AC 58 ms
71,188 KB
testcase_39 AC 59 ms
70,844 KB
testcase_40 AC 59 ms
71,220 KB
testcase_41 AC 59 ms
71,040 KB
testcase_42 AC 60 ms
70,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# lo..hiからk個選択し、dを作れるかどうか?
def ok(lo, hi, k, d):
    if hi - lo + 1 < k:
        return False
    
    mi = 0
    mx = 0
    for i in range(k):
        mi += lo + i
        mx += hi - i
    return mi <= d <= mx

def f(n, d, k):
    if not ok(1, n, k, d):
        return [-1]
    
    lo = 1
    ans = []
    while k > 0:
        if ok(lo + 1, n, k - 1, d - lo):
            ans.append(lo)
            k -= 1
            d -= lo
        lo += 1
    
    return ans

if __name__ == '__main__':
    n, d, k = map(int, input().split())
    print(' '.join(map(str, f(n, d, k))))
0