結果

問題 No.710 チーム戦
ユーザー htkbhtkb
提出日時 2019-03-31 22:43:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,379 ms / 3,000 ms
コード長 377 bytes
コンパイル時間 110 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 14,592 KB
最終ジャッジ日時 2024-05-02 03:34:57
合計ジャッジ時間 22,168 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,624 KB
testcase_01 AC 29 ms
10,752 KB
testcase_02 AC 888 ms
12,544 KB
testcase_03 AC 874 ms
12,544 KB
testcase_04 AC 927 ms
12,672 KB
testcase_05 AC 817 ms
12,416 KB
testcase_06 AC 815 ms
12,672 KB
testcase_07 AC 945 ms
12,672 KB
testcase_08 AC 1,003 ms
12,672 KB
testcase_09 AC 928 ms
12,672 KB
testcase_10 AC 805 ms
12,288 KB
testcase_11 AC 874 ms
12,672 KB
testcase_12 AC 1,050 ms
12,800 KB
testcase_13 AC 857 ms
12,672 KB
testcase_14 AC 958 ms
12,672 KB
testcase_15 AC 856 ms
12,416 KB
testcase_16 AC 906 ms
12,672 KB
testcase_17 AC 752 ms
12,416 KB
testcase_18 AC 924 ms
12,672 KB
testcase_19 AC 992 ms
12,800 KB
testcase_20 AC 914 ms
12,544 KB
testcase_21 AC 874 ms
12,800 KB
testcase_22 AC 1,379 ms
14,592 KB
testcase_23 AC 30 ms
10,752 KB
testcase_24 AC 1,279 ms
14,464 KB
testcase_25 AC 26 ms
10,752 KB
testcase_26 AC 26 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A_costs, B_costs = zip(*(list(map(int, input().split())) for _ in [0]*N))
dp = [sum(B_costs)] * (sum(A_costs)+1)

a_acc = 0
for a_cost, b_cost in zip(A_costs, B_costs):
    for i in range(a_acc, -1, -1):
        if dp[i+a_cost] > dp[i]-b_cost:
            dp[i+a_cost] = dp[i]-b_cost
    a_acc += a_cost

print(min(i if i > v else v for i, v in enumerate(dp)))
0