結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,624 KB
testcase_01 AC 28 ms
10,752 KB
testcase_02 AC 841 ms
12,544 KB
testcase_03 AC 923 ms
12,544 KB
testcase_04 AC 1,054 ms
12,672 KB
testcase_05 AC 820 ms
12,416 KB
testcase_06 AC 824 ms
12,672 KB
testcase_07 AC 943 ms
12,544 KB
testcase_08 AC 993 ms
12,800 KB
testcase_09 AC 919 ms
12,544 KB
testcase_10 AC 736 ms
12,416 KB
testcase_11 AC 857 ms
12,544 KB
testcase_12 AC 1,042 ms
12,672 KB
testcase_13 AC 870 ms
12,544 KB
testcase_14 AC 954 ms
12,672 KB
testcase_15 AC 859 ms
12,416 KB
testcase_16 AC 937 ms
12,672 KB
testcase_17 AC 784 ms
12,416 KB
testcase_18 AC 861 ms
12,544 KB
testcase_19 AC 1,056 ms
12,672 KB
testcase_20 AC 927 ms
12,416 KB
testcase_21 AC 905 ms
12,672 KB
testcase_22 AC 1,172 ms
14,592 KB
testcase_23 AC 26 ms
10,752 KB
testcase_24 AC 1,219 ms
14,464 KB
testcase_25 AC 27 ms
10,624 KB
testcase_26 AC 27 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