結果

問題 No.1583 Building Blocks
ユーザー shino16
提出日時 2021-04-04 17:30:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 349 bytes
コンパイル時間 246 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 66,688 KB
最終ジャッジ日時 2024-09-14 02:45:33
合計ジャッジ時間 3,917 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

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)
dp[0] = 0

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

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