結果

問題 No.115 遠足のおやつ
ユーザー convexineqconvexineq
提出日時 2020-12-09 03:41:33
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 588 bytes
コンパイル時間 644 ms
コンパイル使用メモリ 81,832 KB
実行使用メモリ 85,840 KB
最終ジャッジ日時 2023-10-19 04:39:43
合計ジャッジ時間 5,149 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 54 ms
63,988 KB
testcase_03 RE -
testcase_04 AC 72 ms
78,336 KB
testcase_05 AC 39 ms
53,396 KB
testcase_06 RE -
testcase_07 AC 40 ms
53,396 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 46 ms
61,508 KB
testcase_15 AC 61 ms
72,196 KB
testcase_16 AC 52 ms
68,184 KB
testcase_17 AC 39 ms
53,396 KB
testcase_18 RE -
testcase_19 AC 38 ms
53,396 KB
testcase_20 AC 41 ms
53,396 KB
testcase_21 AC 39 ms
53,396 KB
testcase_22 AC 80 ms
76,852 KB
testcase_23 RE -
testcase_24 AC 107 ms
77,532 KB
testcase_25 AC 42 ms
59,356 KB
testcase_26 AC 39 ms
53,396 KB
testcase_27 AC 47 ms
61,756 KB
testcase_28 AC 51 ms
63,948 KB
testcase_29 AC 44 ms
59,244 KB
testcase_30 AC 89 ms
76,792 KB
testcase_31 AC 43 ms
59,244 KB
testcase_32 AC 61 ms
72,196 KB
testcase_33 AC 41 ms
53,396 KB
testcase_34 AC 81 ms
78,332 KB
testcase_35 AC 49 ms
63,816 KB
testcase_36 AC 130 ms
77,472 KB
testcase_37 AC 51 ms
65,852 KB
testcase_38 AC 286 ms
84,800 KB
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 AC 38 ms
53,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,d,k = map(int,input().split())
#ok[p][q][r] pまでみてq個買ってr円使った 状態から条件を満たせるか?
ok = [[[-1]*(d+1) for _ in range(k+1)] for _ in range(n+1)]
res = []
def dfs(p,q,r):
    if q==k:
        return r==d
    v = ok[p][q][r]
    if v != -1: return v
    for i in range(p+1,n+1):
        if q+1 <= k and r+i <= d and dfs(i,q+1,r+i):
            v = 1
            res.append(i)
            #print(p,q,r,i)
            dfs(i,q+1,r+i)
            break
    else:
        v = 0
    ok[p][q][r] = v
    return v
dfs(0,0,0)
print(*res[::-1] if res else -1)
0