結果

問題 No.54 Happy Hallowe'en
ユーザー vwxyzvwxyz
提出日時 2022-04-10 14:45:06
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
TLE  
実行時間 -
コード長 412 bytes
コンパイル時間 146 ms
コンパイル使用メモリ 10,868 KB
実行使用メモリ 13,940 KB
最終ジャッジ日時 2023-08-20 20:02:44
合計ジャッジ時間 15,334 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
7,800 KB
testcase_01 AC 13 ms
7,944 KB
testcase_02 AC 14 ms
7,836 KB
testcase_03 AC 13 ms
7,948 KB
testcase_04 AC 1,429 ms
8,764 KB
testcase_05 AC 2,631 ms
8,864 KB
testcase_06 AC 3,825 ms
9,032 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