結果

問題 No.1583 Building Blocks
ユーザー shino16shino16
提出日時 2021-04-04 17:35:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 486 bytes
コンパイル時間 356 ms
コンパイル使用メモリ 86,896 KB
実行使用メモリ 85,340 KB
最終ジャッジ日時 2023-10-12 03:02:06
合計ジャッジ時間 6,224 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,508 KB
testcase_01 AC 77 ms
71,200 KB
testcase_02 AC 77 ms
71,224 KB
testcase_03 AC 94 ms
76,228 KB
testcase_04 AC 86 ms
75,892 KB
testcase_05 AC 85 ms
75,660 KB
testcase_06 AC 95 ms
76,304 KB
testcase_07 AC 96 ms
76,372 KB
testcase_08 AC 83 ms
76,024 KB
testcase_09 AC 114 ms
83,656 KB
testcase_10 AC 81 ms
75,956 KB
testcase_11 AC 74 ms
70,996 KB
testcase_12 AC 100 ms
76,408 KB
testcase_13 AC 107 ms
76,404 KB
testcase_14 AC 94 ms
75,992 KB
testcase_15 AC 97 ms
76,500 KB
testcase_16 AC 105 ms
76,408 KB
testcase_17 AC 105 ms
76,608 KB
testcase_18 AC 89 ms
75,852 KB
testcase_19 AC 126 ms
85,340 KB
testcase_20 AC 93 ms
76,384 KB
testcase_21 AC 94 ms
76,252 KB
testcase_22 AC 94 ms
76,184 KB
testcase_23 AC 88 ms
75,952 KB
testcase_24 AC 108 ms
76,528 KB
testcase_25 AC 77 ms
71,504 KB
testcase_26 AC 110 ms
76,528 KB
testcase_27 AC 94 ms
76,188 KB
testcase_28 AC 122 ms
83,260 KB
testcase_29 AC 93 ms
75,996 KB
testcase_30 AC 88 ms
75,944 KB
testcase_31 AC 102 ms
76,496 KB
testcase_32 AC 94 ms
76,352 KB
testcase_33 AC 119 ms
84,960 KB
testcase_34 AC 74 ms
71,204 KB
testcase_35 AC 94 ms
76,104 KB
testcase_36 AC 103 ms
76,604 KB
testcase_37 AC 87 ms
76,264 KB
testcase_38 AC 76 ms
71,304 KB
testcase_39 AC 74 ms
71,208 KB
testcase_40 AC 74 ms
71,228 KB
testcase_41 AC 75 ms
71,204 KB
testcase_42 AC 75 ms
71,240 KB
testcase_43 AC 74 ms
71,512 KB
testcase_44 AC 76 ms
71,188 KB
testcase_45 AC 76 ms
71,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
ws = [list(map(int, input().split())) for _ in range(n)]

ws.sort(key=lambda x: x[0] + x[1])

dp = [[1 << 60] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 0

for t in range(n):
    w, s = ws[t]
    dp[t + 1][0] = 0
    for i in range(n, 0, -1):
        if dp[t][i - 1] <= s:
            dp[t + 1][i] = min(dp[t][i], dp[t][i - 1] + w)
        else:
            dp[t + 1][i] = dp[t][i]

for i in range(n, 0, -1):
    if dp[n][i] != 1 << 60:
        print(i)
        break
0