結果

問題 No.1583 Building Blocks
ユーザー shino16shino16
提出日時 2021-04-04 17:35:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 442 ms / 2,000 ms
コード長 486 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 10,860 KB
実行使用メモリ 19,844 KB
最終ジャッジ日時 2023-10-12 03:02:04
合計ジャッジ時間 6,923 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,756 KB
testcase_01 AC 17 ms
7,848 KB
testcase_02 AC 17 ms
7,812 KB
testcase_03 AC 107 ms
10,104 KB
testcase_04 AC 25 ms
8,384 KB
testcase_05 AC 19 ms
7,876 KB
testcase_06 AC 100 ms
10,084 KB
testcase_07 AC 121 ms
10,636 KB
testcase_08 AC 20 ms
8,220 KB
testcase_09 AC 304 ms
14,560 KB
testcase_10 AC 17 ms
7,788 KB
testcase_11 AC 17 ms
7,876 KB
testcase_12 AC 159 ms
11,356 KB
testcase_13 AC 251 ms
12,996 KB
testcase_14 AC 75 ms
9,340 KB
testcase_15 AC 142 ms
10,968 KB
testcase_16 AC 220 ms
12,640 KB
testcase_17 AC 215 ms
12,940 KB
testcase_18 AC 37 ms
8,720 KB
testcase_19 AC 442 ms
17,676 KB
testcase_20 AC 78 ms
9,812 KB
testcase_21 AC 78 ms
9,732 KB
testcase_22 AC 90 ms
10,080 KB
testcase_23 AC 29 ms
8,516 KB
testcase_24 AC 301 ms
16,604 KB
testcase_25 AC 16 ms
7,812 KB
testcase_26 AC 369 ms
19,020 KB
testcase_27 AC 86 ms
10,344 KB
testcase_28 AC 422 ms
19,844 KB
testcase_29 AC 52 ms
9,420 KB
testcase_30 AC 28 ms
8,620 KB
testcase_31 AC 201 ms
12,452 KB
testcase_32 AC 97 ms
10,020 KB
testcase_33 AC 370 ms
16,216 KB
testcase_34 AC 16 ms
7,840 KB
testcase_35 AC 107 ms
10,328 KB
testcase_36 AC 238 ms
13,284 KB
testcase_37 AC 32 ms
8,560 KB
testcase_38 AC 16 ms
7,808 KB
testcase_39 AC 16 ms
7,832 KB
testcase_40 AC 16 ms
7,808 KB
testcase_41 AC 16 ms
7,788 KB
testcase_42 AC 16 ms
7,796 KB
testcase_43 AC 16 ms
7,816 KB
testcase_44 AC 17 ms
7,808 KB
testcase_45 AC 16 ms
7,724 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