結果

問題 No.115 遠足のおやつ
ユーザー convexineqconvexineq
提出日時 2020-12-09 03:43:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 259 ms / 5,000 ms
コード長 597 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 88,300 KB
最終ジャッジ日時 2023-08-31 01:00:59
合計ジャッジ時間 5,042 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
71,376 KB
testcase_01 AC 65 ms
71,444 KB
testcase_02 AC 72 ms
76,216 KB
testcase_03 AC 59 ms
71,464 KB
testcase_04 AC 85 ms
80,032 KB
testcase_05 AC 64 ms
71,324 KB
testcase_06 AC 60 ms
71,584 KB
testcase_07 AC 61 ms
71,324 KB
testcase_08 AC 59 ms
71,456 KB
testcase_09 AC 57 ms
71,644 KB
testcase_10 AC 61 ms
71,272 KB
testcase_11 AC 59 ms
71,388 KB
testcase_12 AC 58 ms
71,664 KB
testcase_13 AC 60 ms
71,516 KB
testcase_14 AC 65 ms
76,016 KB
testcase_15 AC 76 ms
79,012 KB
testcase_16 AC 68 ms
76,564 KB
testcase_17 AC 62 ms
71,380 KB
testcase_18 AC 60 ms
71,460 KB
testcase_19 AC 62 ms
71,272 KB
testcase_20 AC 61 ms
71,288 KB
testcase_21 AC 60 ms
71,420 KB
testcase_22 AC 89 ms
78,996 KB
testcase_23 AC 73 ms
76,520 KB
testcase_24 AC 112 ms
79,592 KB
testcase_25 AC 65 ms
75,688 KB
testcase_26 AC 60 ms
71,316 KB
testcase_27 AC 67 ms
76,408 KB
testcase_28 AC 70 ms
76,420 KB
testcase_29 AC 65 ms
75,724 KB
testcase_30 AC 101 ms
78,928 KB
testcase_31 AC 66 ms
75,516 KB
testcase_32 AC 77 ms
79,104 KB
testcase_33 AC 62 ms
71,472 KB
testcase_34 AC 89 ms
80,260 KB
testcase_35 AC 69 ms
76,200 KB
testcase_36 AC 128 ms
80,304 KB
testcase_37 AC 67 ms
76,540 KB
testcase_38 AC 251 ms
88,004 KB
testcase_39 AC 259 ms
88,300 KB
testcase_40 AC 61 ms
71,300 KB
testcase_41 AC 61 ms
71,452 KB
testcase_42 AC 60 ms
71,380 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)
if res: print(*res[::-1])
else: print(-1)
0