結果

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

ソースコード

diff #

n = int(input())
ws = [list(map(int,input().split())) for i in range(n)]
ws.sort(key=sum)
INF = 1<<60
dp = [INF]*(n+1)
dp[0] = 0
for w,s in ws:
    for i in range(n)[::-1]:
        if dp[i] <= s: dp[i+1] = min(dp[i+1],dp[i]+w)
print((dp+[INF]).index(INF)-1)
0