結果

問題 No.1583 Building Blocks
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-08-14 13:18:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 587 ms / 2,000 ms
コード長 510 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 10,812 KB
実行使用メモリ 20,108 KB
最終ジャッジ日時 2023-10-12 03:06:11
合計ジャッジ時間 8,415 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,184 KB
testcase_01 AC 16 ms
8,292 KB
testcase_02 AC 16 ms
8,192 KB
testcase_03 AC 127 ms
10,336 KB
testcase_04 AC 28 ms
8,356 KB
testcase_05 AC 20 ms
8,232 KB
testcase_06 AC 121 ms
10,096 KB
testcase_07 AC 154 ms
10,676 KB
testcase_08 AC 21 ms
8,340 KB
testcase_09 AC 398 ms
14,620 KB
testcase_10 AC 17 ms
8,216 KB
testcase_11 AC 16 ms
8,320 KB
testcase_12 AC 207 ms
11,544 KB
testcase_13 AC 309 ms
13,072 KB
testcase_14 AC 93 ms
9,592 KB
testcase_15 AC 181 ms
10,984 KB
testcase_16 AC 279 ms
12,596 KB
testcase_17 AC 272 ms
12,908 KB
testcase_18 AC 44 ms
8,968 KB
testcase_19 AC 587 ms
17,692 KB
testcase_20 AC 98 ms
9,840 KB
testcase_21 AC 96 ms
10,012 KB
testcase_22 AC 111 ms
10,108 KB
testcase_23 AC 33 ms
8,600 KB
testcase_24 AC 370 ms
16,608 KB
testcase_25 AC 16 ms
8,252 KB
testcase_26 AC 496 ms
19,136 KB
testcase_27 AC 107 ms
10,416 KB
testcase_28 AC 552 ms
20,108 KB
testcase_29 AC 61 ms
9,376 KB
testcase_30 AC 30 ms
8,696 KB
testcase_31 AC 259 ms
12,424 KB
testcase_32 AC 121 ms
10,060 KB
testcase_33 AC 472 ms
16,204 KB
testcase_34 AC 16 ms
8,240 KB
testcase_35 AC 136 ms
10,376 KB
testcase_36 AC 303 ms
13,324 KB
testcase_37 AC 36 ms
8,604 KB
testcase_38 AC 16 ms
8,236 KB
testcase_39 AC 16 ms
8,112 KB
testcase_40 AC 16 ms
8,236 KB
testcase_41 AC 16 ms
8,108 KB
testcase_42 AC 15 ms
8,120 KB
testcase_43 AC 16 ms
8,192 KB
testcase_44 AC 16 ms
8,176 KB
testcase_45 AC 16 ms
8,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
ws = [list(map(int, input().split())) for i in range(n)]
ws.sort(key=lambda x: x[0] + x[1])
dp = [[10 ** 18] * (n + 1) for i in range(n + 1)]
dp[0][0] = 0
for i in range(1, n + 1):
    for j in range(n + 1):
        if j == 0: dp[i][j] = 0; continue
        if dp[i - 1][j - 1] > ws[i - 1][1]:
            dp[i][j] = dp[i - 1][j]
        else:
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - 1] + ws[i - 1][0])
for i in range(1, n + 1)[::-1]:
    if dp[n][i] != 10 ** 18: exit(print(i))
0