結果

問題 No.54 Happy Hallowe'en
ユーザー H3PO4H3PO4
提出日時 2023-02-19 14:27:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 182 ms / 5,000 ms
コード長 318 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 10,720 KB
実行使用メモリ 31,264 KB
最終ジャッジ日時 2023-09-27 20:32:49
合計ジャッジ時間 3,752 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
29,684 KB
testcase_01 AC 122 ms
29,776 KB
testcase_02 AC 122 ms
29,784 KB
testcase_03 AC 131 ms
29,760 KB
testcase_04 AC 138 ms
30,224 KB
testcase_05 AC 149 ms
30,532 KB
testcase_06 AC 152 ms
30,620 KB
testcase_07 AC 162 ms
30,956 KB
testcase_08 AC 174 ms
31,264 KB
testcase_09 AC 182 ms
30,964 KB
testcase_10 AC 123 ms
29,700 KB
testcase_11 AC 124 ms
29,724 KB
testcase_12 AC 174 ms
31,140 KB
testcase_13 AC 175 ms
30,936 KB
testcase_14 AC 125 ms
29,716 KB
testcase_15 AC 126 ms
29,772 KB
testcase_16 AC 126 ms
29,744 KB
testcase_17 AC 126 ms
29,688 KB
testcase_18 AC 125 ms
29,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

N = int(input())
MAX = 20000

homes = [tuple(map(int, input().split())) for _ in range(N)]
homes.sort(key=lambda x: x[0] + x[1])

dp = np.zeros(MAX + 1, dtype=bool)
dp[0] = True
for v, t in homes:
    new_dp = dp.copy()
    new_dp[v:v + t] |= dp[:t]
    dp = new_dp

print(np.nonzero(dp)[0].max())
0