結果
問題 | No.951 【本日限定】1枚頼むともう1枚無料! |
ユーザー | persimmon-persimmon |
提出日時 | 2022-04-04 11:22:44 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 831 bytes |
コンパイル時間 | 159 ms |
コンパイル使用メモリ | 10,876 KB |
実行使用メモリ | 15,568 KB |
最終ジャッジ日時 | 2023-08-16 12:58:41 |
合計ジャッジ時間 | 5,217 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 20 ms
15,568 KB |
testcase_01 | AC | 19 ms
8,500 KB |
testcase_02 | AC | 21 ms
8,580 KB |
testcase_03 | AC | 17 ms
8,568 KB |
testcase_04 | AC | 18 ms
8,700 KB |
testcase_05 | AC | 17 ms
8,568 KB |
testcase_06 | AC | 20 ms
8,540 KB |
testcase_07 | AC | 18 ms
8,720 KB |
testcase_08 | AC | 18 ms
8,612 KB |
testcase_09 | AC | 405 ms
9,280 KB |
testcase_10 | AC | 235 ms
9,260 KB |
testcase_11 | AC | 182 ms
8,880 KB |
testcase_12 | TLE | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
testcase_49 | -- | - |
testcase_50 | -- | - |
testcase_51 | -- | - |
testcase_52 | -- | - |
testcase_53 | -- | - |
testcase_54 | -- | - |
ソースコード
def main2(n,k,pd): from collections import defaultdict pd.sort(key=lambda x:x[0],reverse=True) dp0=defaultdict(lambda:-1) dp1=defaultdict(lambda:-1) dp0[0]=0 for _,(p,d) in enumerate(pd): ndp0=defaultdict(lambda:-1) ndp1=defaultdict(lambda:-1) for i in dp0: # チケットなし if i+p<=k: ndp1[i+p]=max(ndp1[i+p],dp0[i]+d) ndp0[i]=max(ndp0[i],dp0[i]) for i in dp1: # チケットあり ndp0[i]=max(ndp0[i],dp1[i]+d) ndp1[i]=max(ndp1[i],dp1[i]) dp0=ndp0 dp1=ndp1 return max(max(dp0.values()),max(dp1.values())) if __name__=='__main__': n,k=map(int,input().split()) pd=[list(map(int,input().split())) for _ in range(n)] ret2=main2(n,k,pd) print(ret2)