結果

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

ソースコード

diff #

n = int(input())
ws = sorted((list(map(int,input().split())) for i in range(n)), key=sum)
INF = 1<<60
dp = [INF]*(n+2)
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.index(INF)-1)
0