結果

問題 No.54 Happy Hallowe'en
ユーザー shotoyooshotoyoo
提出日時 2021-07-22 18:06:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 124 ms / 5,000 ms
コード長 589 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 86,924 KB
実行使用メモリ 78,400 KB
最終ジャッジ日時 2023-09-24 14:19:01
合計ジャッジ時間 3,231 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,224 KB
testcase_01 AC 72 ms
71,244 KB
testcase_02 AC 72 ms
71,356 KB
testcase_03 AC 72 ms
71,196 KB
testcase_04 AC 109 ms
77,368 KB
testcase_05 AC 96 ms
77,624 KB
testcase_06 AC 100 ms
77,688 KB
testcase_07 AC 107 ms
78,156 KB
testcase_08 AC 113 ms
77,924 KB
testcase_09 AC 124 ms
78,368 KB
testcase_10 AC 71 ms
71,420 KB
testcase_11 AC 71 ms
71,228 KB
testcase_12 AC 107 ms
78,136 KB
testcase_13 AC 117 ms
78,400 KB
testcase_14 AC 72 ms
71,432 KB
testcase_15 AC 71 ms
71,232 KB
testcase_16 AC 71 ms
71,180 KB
testcase_17 AC 74 ms
71,424 KB
testcase_18 AC 73 ms
71,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


n = int(input())
vt = [tuple(map(int, input().split())) for _ in range(n)]
vt.sort(key=lambda item: item[0]+item[1])
dp = 1
mask0 = (1<<30000)-1
for v,t in vt:
    # t未満のところはv増やせる
    mask = (1<<t) - 1
    dp = dp | (dp&mask)<<v
    dp &= mask0
for i in range(dp.bit_length())[::-1]:
    if dp>>i&1:
        ans = i
        break
print(ans)
0