結果

問題 No.1583 Building Blocks
ユーザー ayaoniayaoni
提出日時 2021-07-03 21:27:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 875 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 87,152 KB
実行使用メモリ 84,692 KB
最終ジャッジ日時 2023-10-12 03:05:37
合計ジャッジ時間 6,261 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,292 KB
testcase_01 AC 77 ms
71,212 KB
testcase_02 AC 80 ms
71,232 KB
testcase_03 AC 94 ms
76,396 KB
testcase_04 AC 84 ms
75,928 KB
testcase_05 AC 86 ms
75,932 KB
testcase_06 AC 91 ms
76,552 KB
testcase_07 AC 91 ms
76,472 KB
testcase_08 AC 85 ms
75,932 KB
testcase_09 AC 100 ms
76,260 KB
testcase_10 AC 83 ms
76,260 KB
testcase_11 AC 78 ms
71,168 KB
testcase_12 AC 96 ms
76,440 KB
testcase_13 AC 98 ms
76,284 KB
testcase_14 AC 92 ms
76,280 KB
testcase_15 AC 97 ms
76,372 KB
testcase_16 AC 98 ms
76,216 KB
testcase_17 AC 97 ms
76,572 KB
testcase_18 AC 89 ms
75,836 KB
testcase_19 AC 114 ms
84,692 KB
testcase_20 AC 92 ms
76,452 KB
testcase_21 AC 93 ms
76,208 KB
testcase_22 AC 93 ms
76,468 KB
testcase_23 AC 88 ms
76,188 KB
testcase_24 AC 97 ms
76,184 KB
testcase_25 AC 79 ms
71,236 KB
testcase_26 AC 100 ms
76,212 KB
testcase_27 AC 91 ms
76,524 KB
testcase_28 AC 103 ms
76,240 KB
testcase_29 AC 85 ms
76,556 KB
testcase_30 AC 84 ms
76,060 KB
testcase_31 AC 92 ms
76,392 KB
testcase_32 AC 89 ms
76,456 KB
testcase_33 AC 96 ms
76,344 KB
testcase_34 AC 75 ms
71,400 KB
testcase_35 AC 89 ms
76,508 KB
testcase_36 AC 98 ms
76,496 KB
testcase_37 AC 85 ms
75,848 KB
testcase_38 AC 77 ms
71,408 KB
testcase_39 AC 77 ms
71,488 KB
testcase_40 AC 76 ms
71,300 KB
testcase_41 AC 76 ms
71,452 KB
testcase_42 AC 76 ms
71,304 KB
testcase_43 AC 75 ms
71,556 KB
testcase_44 AC 78 ms
71,284 KB
testcase_45 AC 77 ms
71,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N = I()
WS = []
for _ in range(N):
    w,s = MI()
    WS.append((w+s,w,s))
WS.sort()

inf = 10**18
dp = [[inf]*(N+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    a,w,s = WS[i-1]
    for j in range(i+1):
        dp[i][j] = dp[i-1][j]
        if j >= 1 and s >= dp[i-1][j-1]:
            dp[i][j] = min(dp[i][j],dp[i-1][j-1]+w)

for j in range(N,-1,-1):
    if dp[-1][j] < inf:
        print(j)
        break
0