結果

問題 No.2093 Shio Ramen
ユーザー ThetaTheta
提出日時 2022-10-11 17:16:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 570 ms / 2,000 ms
コード長 804 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 10,800 KB
実行使用メモリ 17,140 KB
最終ジャッジ日時 2023-09-07 18:38:33
合計ジャッジ時間 8,801 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,848 KB
testcase_01 AC 16 ms
7,892 KB
testcase_02 AC 17 ms
7,940 KB
testcase_03 AC 16 ms
7,780 KB
testcase_04 AC 15 ms
7,792 KB
testcase_05 AC 15 ms
7,772 KB
testcase_06 AC 15 ms
7,788 KB
testcase_07 AC 15 ms
7,848 KB
testcase_08 AC 16 ms
7,960 KB
testcase_09 AC 78 ms
9,252 KB
testcase_10 AC 391 ms
13,908 KB
testcase_11 AC 34 ms
8,528 KB
testcase_12 AC 58 ms
8,924 KB
testcase_13 AC 34 ms
8,540 KB
testcase_14 AC 54 ms
8,868 KB
testcase_15 AC 284 ms
12,512 KB
testcase_16 AC 110 ms
9,600 KB
testcase_17 AC 77 ms
9,464 KB
testcase_18 AC 553 ms
16,376 KB
testcase_19 AC 350 ms
13,360 KB
testcase_20 AC 198 ms
11,240 KB
testcase_21 AC 261 ms
12,064 KB
testcase_22 AC 251 ms
12,132 KB
testcase_23 AC 562 ms
17,104 KB
testcase_24 AC 559 ms
17,004 KB
testcase_25 AC 570 ms
17,020 KB
testcase_26 AC 558 ms
17,020 KB
testcase_27 AC 561 ms
17,140 KB
testcase_28 AC 563 ms
17,140 KB
testcase_29 AC 565 ms
16,948 KB
testcase_30 AC 565 ms
17,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N, I = map(int, input().split())
    salt_taste_list = []
    for _ in range(N):
        salt_taste_list.append(tuple(map(int, input().split())))

    salt_taste_dp_table = [[0 for _ in range(I+1)] for _ in range(N+1)]
    for n in range(1, N+1):
        for i in range(1, I+1):
            salt_taste_dp_table[n][i] = max(
                salt_taste_dp_table[n][i-1],
                salt_taste_dp_table[n-1][i]
            )
            if i - salt_taste_list[n-1][0] >= 0:
                salt_taste_dp_table[n][i] = max(
                    salt_taste_dp_table[n][i],
                    salt_taste_dp_table[n-1][i - salt_taste_list[n-1][0]]
                    + salt_taste_list[n-1][1]
                )

    print(salt_taste_dp_table[N][I])


if __name__ == "__main__":
    main()
0