結果
問題 |
No.54 Happy Hallowe'en
|
ユーザー |
![]() |
提出日時 | 2021-11-04 01:04:21 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 75 ms / 5,000 ms |
コード長 | 426 bytes |
コンパイル時間 | 237 ms |
コンパイル使用メモリ | 82,240 KB |
実行使用メモリ | 76,544 KB |
最終ジャッジ日時 | 2024-10-13 17:28:10 |
合計ジャッジ時間 | 1,848 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
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()