結果

問題 No.54 Happy Hallowe'en
ユーザー brthyyjpbrthyyjp
提出日時 2021-11-04 01:04:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 118 ms / 5,000 ms
コード長 426 bytes
コンパイル時間 1,515 ms
コンパイル使用メモリ 87,076 KB
実行使用メモリ 77,572 KB
最終ジャッジ日時 2023-08-03 20:16:07
合計ジャッジ時間 4,459 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,188 KB
testcase_01 AC 73 ms
70,876 KB
testcase_02 AC 74 ms
71,124 KB
testcase_03 AC 74 ms
71,088 KB
testcase_04 AC 96 ms
76,644 KB
testcase_05 AC 93 ms
77,112 KB
testcase_06 AC 98 ms
77,360 KB
testcase_07 AC 104 ms
77,480 KB
testcase_08 AC 111 ms
77,068 KB
testcase_09 AC 118 ms
77,536 KB
testcase_10 AC 74 ms
70,888 KB
testcase_11 AC 74 ms
71,364 KB
testcase_12 AC 103 ms
77,164 KB
testcase_13 AC 111 ms
77,572 KB
testcase_14 AC 74 ms
71,248 KB
testcase_15 AC 74 ms
71,308 KB
testcase_16 AC 74 ms
71,036 KB
testcase_17 AC 76 ms
71,396 KB
testcase_18 AC 75 ms
71,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

n = int(input())
VT = []
for i in range(n):
    v, t = map(int, input().split())
    VT.append((v,t))

VT.sort(key=lambda x: x[0]+x[1])
dp = 1
limit = (1<<30000)-1
for v, t in VT:
    mask = (1<<t)-1
    dp |= (dp&mask)<<v
    dp &= limit
l = dp.bit_length()
for i in reversed(range(l)):
    if (dp>>i) & 1:
        print(i)
        exit()
0