結果

問題 No.54 Happy Hallowe'en
ユーザー Ricky_ponRicky_pon
提出日時 2020-05-22 10:03:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 453 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 18,336 KB
最終ジャッジ日時 2024-04-14 22:02:25
合計ジャッジ時間 7,220 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
10,880 KB
testcase_01 AC 42 ms
10,752 KB
testcase_02 AC 48 ms
10,752 KB
testcase_03 AC 37 ms
11,008 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

n = int(readline())
p = sorted([list(map(int, readline().split())) for _ in range(n)], key=lambda x: sum(x))
dp = [-1 for _ in range(10010)]
dp[0] = 0
ans = 0
for i in range(n):
    for j in range(10010):
        if 0 <= j - p[i][0] < p[i][1] and dp[j-p[i][0]] >= 0:
            dp[j] = max(dp[j], dp[j-p[i][0]] + 1)
            ans = max(ans, j)
print(ans)
0