結果

問題 No.115 遠足のおやつ
ユーザー convexineqconvexineq
提出日時 2020-12-09 02:22:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 119 ms / 5,000 ms
コード長 656 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 86,124 KB
最終ジャッジ日時 2023-08-31 01:00:50
合計ジャッジ時間 5,778 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,228 KB
testcase_01 AC 84 ms
75,432 KB
testcase_02 AC 84 ms
75,396 KB
testcase_03 AC 78 ms
75,564 KB
testcase_04 AC 99 ms
75,796 KB
testcase_05 AC 72 ms
70,976 KB
testcase_06 AC 71 ms
70,976 KB
testcase_07 AC 81 ms
75,352 KB
testcase_08 AC 79 ms
75,492 KB
testcase_09 AC 83 ms
75,872 KB
testcase_10 AC 84 ms
75,572 KB
testcase_11 AC 78 ms
75,524 KB
testcase_12 AC 82 ms
75,496 KB
testcase_13 AC 72 ms
71,172 KB
testcase_14 AC 83 ms
75,516 KB
testcase_15 AC 96 ms
76,436 KB
testcase_16 AC 106 ms
76,204 KB
testcase_17 AC 89 ms
76,216 KB
testcase_18 AC 77 ms
75,588 KB
testcase_19 AC 83 ms
76,072 KB
testcase_20 AC 84 ms
75,956 KB
testcase_21 AC 81 ms
75,928 KB
testcase_22 AC 93 ms
76,148 KB
testcase_23 AC 87 ms
75,556 KB
testcase_24 AC 92 ms
76,008 KB
testcase_25 AC 92 ms
75,944 KB
testcase_26 AC 86 ms
76,060 KB
testcase_27 AC 90 ms
76,320 KB
testcase_28 AC 86 ms
75,792 KB
testcase_29 AC 87 ms
75,900 KB
testcase_30 AC 92 ms
76,236 KB
testcase_31 AC 88 ms
75,716 KB
testcase_32 AC 95 ms
76,012 KB
testcase_33 AC 84 ms
75,876 KB
testcase_34 AC 98 ms
75,912 KB
testcase_35 AC 90 ms
75,992 KB
testcase_36 AC 94 ms
75,900 KB
testcase_37 AC 94 ms
75,724 KB
testcase_38 AC 118 ms
85,140 KB
testcase_39 AC 119 ms
86,124 KB
testcase_40 AC 73 ms
70,984 KB
testcase_41 AC 71 ms
70,948 KB
testcase_42 AC 72 ms
70,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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