結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,908 KB
testcase_01 AC 19 ms
7,744 KB
testcase_02 AC 883 ms
9,816 KB
testcase_03 AC 884 ms
9,876 KB
testcase_04 AC 965 ms
10,200 KB
testcase_05 AC 851 ms
9,852 KB
testcase_06 AC 831 ms
9,812 KB
testcase_07 AC 1,009 ms
10,032 KB
testcase_08 AC 940 ms
10,072 KB
testcase_09 AC 965 ms
10,016 KB
testcase_10 AC 769 ms
9,904 KB
testcase_11 AC 864 ms
9,932 KB
testcase_12 AC 987 ms
10,232 KB
testcase_13 AC 915 ms
10,116 KB
testcase_14 AC 914 ms
10,116 KB
testcase_15 AC 885 ms
9,764 KB
testcase_16 AC 949 ms
10,056 KB
testcase_17 AC 763 ms
9,948 KB
testcase_18 AC 863 ms
9,856 KB
testcase_19 AC 1,036 ms
10,076 KB
testcase_20 AC 888 ms
9,860 KB
testcase_21 AC 892 ms
10,212 KB
testcase_22 AC 1,166 ms
11,960 KB
testcase_23 AC 17 ms
7,748 KB
testcase_24 AC 1,266 ms
11,704 KB
testcase_25 AC 16 ms
7,752 KB
testcase_26 AC 16 ms
7,800 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