結果

問題 No.710 チーム戦
ユーザー shotoyooshotoyoo
提出日時 2021-06-16 22:48:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 222 ms / 3,000 ms
コード長 691 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 154,968 KB
最終ジャッジ日時 2023-08-30 04:16:05
合計ジャッジ時間 5,592 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,352 KB
testcase_01 AC 84 ms
75,992 KB
testcase_02 AC 151 ms
114,368 KB
testcase_03 AC 153 ms
115,088 KB
testcase_04 AC 158 ms
117,456 KB
testcase_05 AC 148 ms
113,192 KB
testcase_06 AC 154 ms
116,708 KB
testcase_07 AC 154 ms
116,244 KB
testcase_08 AC 154 ms
118,164 KB
testcase_09 AC 154 ms
115,788 KB
testcase_10 AC 148 ms
114,948 KB
testcase_11 AC 152 ms
116,672 KB
testcase_12 AC 156 ms
118,140 KB
testcase_13 AC 152 ms
116,504 KB
testcase_14 AC 154 ms
116,864 KB
testcase_15 AC 148 ms
113,784 KB
testcase_16 AC 153 ms
117,936 KB
testcase_17 AC 153 ms
118,820 KB
testcase_18 AC 153 ms
115,672 KB
testcase_19 AC 157 ms
119,736 KB
testcase_20 AC 150 ms
116,408 KB
testcase_21 AC 155 ms
119,392 KB
testcase_22 AC 219 ms
154,968 KB
testcase_23 AC 78 ms
76,076 KB
testcase_24 AC 222 ms
151,060 KB
testcase_25 AC 71 ms
71,332 KB
testcase_26 AC 73 ms
71,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
m = max(sum((ab[i][0] for i in range(n))), sum((ab[i][1] for i in range(n))))
inf = 10**12
dp = [inf]*(m+1)
dp[0] = 0
for a,b in ab:
    ndp = [inf]*(m+1)
    for j in range(m+1)[::-1]:
        if j-a>=0:
            ndp[j] = min(dp[j]+b, dp[j-a])
        else:
            ndp[j] = dp[j] + b
    dp = ndp
ans = float("inf")
for j in range(m+1):
    ans = min(ans ,max(j, dp[j]))
print(ans)
0