結果

問題 No.1583 Building Blocks
ユーザー shotoyooshotoyoo
提出日時 2021-07-02 22:03:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 644 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 86,888 KB
実行使用メモリ 77,188 KB
最終ジャッジ日時 2023-10-12 03:02:36
合計ジャッジ時間 6,134 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,240 KB
testcase_01 AC 76 ms
71,200 KB
testcase_02 AC 78 ms
71,180 KB
testcase_03 AC 91 ms
76,376 KB
testcase_04 AC 85 ms
75,956 KB
testcase_05 AC 83 ms
75,752 KB
testcase_06 AC 89 ms
76,284 KB
testcase_07 AC 92 ms
76,528 KB
testcase_08 AC 85 ms
75,796 KB
testcase_09 AC 103 ms
77,144 KB
testcase_10 AC 83 ms
75,788 KB
testcase_11 AC 78 ms
71,296 KB
testcase_12 AC 94 ms
76,456 KB
testcase_13 AC 100 ms
76,724 KB
testcase_14 AC 92 ms
76,512 KB
testcase_15 AC 96 ms
76,728 KB
testcase_16 AC 99 ms
76,720 KB
testcase_17 AC 100 ms
76,456 KB
testcase_18 AC 90 ms
76,348 KB
testcase_19 AC 107 ms
77,160 KB
testcase_20 AC 90 ms
76,368 KB
testcase_21 AC 90 ms
76,504 KB
testcase_22 AC 92 ms
76,312 KB
testcase_23 AC 86 ms
75,916 KB
testcase_24 AC 99 ms
76,508 KB
testcase_25 AC 78 ms
71,456 KB
testcase_26 AC 102 ms
76,716 KB
testcase_27 AC 91 ms
76,484 KB
testcase_28 AC 103 ms
76,508 KB
testcase_29 AC 89 ms
76,452 KB
testcase_30 AC 86 ms
75,796 KB
testcase_31 AC 97 ms
76,548 KB
testcase_32 AC 92 ms
76,368 KB
testcase_33 AC 105 ms
77,188 KB
testcase_34 AC 77 ms
71,284 KB
testcase_35 AC 94 ms
76,428 KB
testcase_36 AC 99 ms
76,700 KB
testcase_37 AC 89 ms
76,648 KB
testcase_38 AC 78 ms
71,012 KB
testcase_39 AC 78 ms
71,104 KB
testcase_40 AC 80 ms
71,128 KB
testcase_41 AC 78 ms
71,556 KB
testcase_42 AC 79 ms
71,200 KB
testcase_43 AC 78 ms
71,272 KB
testcase_44 AC 77 ms
71,504 KB
testcase_45 AC 77 ms
71,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


n = int(input())
ws = [list(map(int, input().split())) for _ in range(n)]
ws.sort(key=lambda i: sum(i))
inf = 10**12
dp = [inf]*(n+1)
dp[0] = 0
for i in range(n):
    w,s = ws[i]
    ndp = [inf]*(n+1)
    for j in range(n):
        if dp[j]<=s:
            ndp[j+1] = min(ndp[j+1], dp[j]+w)
        ndp[j] = min(ndp[j], dp[j])
    dp = ndp
for i in range(n+1)[::-1]:
    if dp[i]<inf:
        break
ans = i
print(ans)
0