結果

問題 No.710 チーム戦
ユーザー htkbhtkb
提出日時 2019-03-31 22:43:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,272 ms / 3,000 ms
コード長 377 bytes
コンパイル時間 940 ms
コンパイル使用メモリ 10,704 KB
実行使用メモリ 12,000 KB
最終ジャッジ日時 2023-08-14 15:30:45
合計ジャッジ時間 23,578 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,852 KB
testcase_01 AC 18 ms
7,832 KB
testcase_02 AC 865 ms
9,860 KB
testcase_03 AC 936 ms
9,924 KB
testcase_04 AC 999 ms
10,120 KB
testcase_05 AC 821 ms
9,856 KB
testcase_06 AC 803 ms
9,724 KB
testcase_07 AC 948 ms
10,052 KB
testcase_08 AC 951 ms
10,060 KB
testcase_09 AC 958 ms
10,040 KB
testcase_10 AC 747 ms
9,796 KB
testcase_11 AC 840 ms
9,924 KB
testcase_12 AC 1,030 ms
10,208 KB
testcase_13 AC 857 ms
9,988 KB
testcase_14 AC 918 ms
10,044 KB
testcase_15 AC 826 ms
9,788 KB
testcase_16 AC 932 ms
10,124 KB
testcase_17 AC 803 ms
9,856 KB
testcase_18 AC 856 ms
9,924 KB
testcase_19 AC 1,006 ms
10,188 KB
testcase_20 AC 860 ms
9,828 KB
testcase_21 AC 909 ms
10,124 KB
testcase_22 AC 1,236 ms
12,000 KB
testcase_23 AC 16 ms
7,812 KB
testcase_24 AC 1,272 ms
11,644 KB
testcase_25 AC 15 ms
7,812 KB
testcase_26 AC 15 ms
7,824 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