結果

問題 No.1583 Building Blocks
ユーザー Kude
提出日時 2021-07-03 00:00:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 322 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 82,484 KB
実行使用メモリ 68,480 KB
最終ジャッジ日時 2024-09-14 02:50:30
合計ジャッジ時間 3,884 ms
ジャッジサーバーID
(参考情報)
judge6 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
ws = sorted((tuple(map(int, input().split())) for _ in range(n)), key=lambda p: sum(p))
dp = [0]
for w, s in ws:
    sz = len(dp)
    if dp[-1] <= s:
        dp.append(dp[-1] + w)
    for i in range(sz - 1)[::-1]:
        if dp[i] <= s:
            dp[i + 1] = min(dp[i + 1], dp[i] + w)
print(len(dp) - 1)
0