結果

問題 No.54 Happy Hallowe'en
ユーザー vwxyzvwxyz
提出日時 2022-04-10 14:45:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 412 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 17,408 KB
最終ジャッジ日時 2024-05-08 02:29:04
合計ジャッジ時間 17,166 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,880 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 32 ms
10,624 KB
testcase_03 AC 31 ms
10,752 KB
testcase_04 AC 1,844 ms
11,264 KB
testcase_05 AC 2,952 ms
11,520 KB
testcase_06 AC 4,889 ms
11,776 KB
testcase_07 TLE -
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
readline=sys.stdin.readline

N=int(readline())
V,T=[],[]
for i in range(N):
    v,t=map(int,readline().split())
    V.append(v)
    T.append(t)
M=max(T)+max(V)
dp=[False]*(M+1)
dp[0]=True
for i in sorted([i for i in range(N)],key=lambda i:V[i]+T[i]):
    for j in range(min(M,T[i]+V[i]-1),V[i]-1,-1):
        dp[j]|=dp[j-V[i]]
ans=0
for i in range(M+1):
    if dp[i]:
        ans=max(ans,i)
print(ans)
0