結果

問題 No.54 Happy Hallowe'en
ユーザー brthyyjpbrthyyjp
提出日時 2021-11-04 01:04:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 74 ms / 5,000 ms
コード長 426 bytes
コンパイル時間 438 ms
コンパイル使用メモリ 82,140 KB
実行使用メモリ 76,312 KB
最終ジャッジ日時 2024-04-21 18:32:45
合計ジャッジ時間 2,031 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
51,944 KB
testcase_01 AC 35 ms
51,712 KB
testcase_02 AC 36 ms
51,968 KB
testcase_03 AC 37 ms
51,968 KB
testcase_04 AC 51 ms
70,912 KB
testcase_05 AC 61 ms
76,032 KB
testcase_06 AC 63 ms
76,044 KB
testcase_07 AC 64 ms
76,276 KB
testcase_08 AC 69 ms
75,900 KB
testcase_09 AC 74 ms
76,244 KB
testcase_10 AC 37 ms
52,096 KB
testcase_11 AC 34 ms
52,096 KB
testcase_12 AC 64 ms
76,312 KB
testcase_13 AC 71 ms
76,160 KB
testcase_14 AC 35 ms
52,012 KB
testcase_15 AC 34 ms
52,096 KB
testcase_16 AC 33 ms
52,224 KB
testcase_17 AC 34 ms
51,968 KB
testcase_18 AC 32 ms
51,712 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