結果
問題 | No.951 【本日限定】1枚頼むともう1枚無料! |
ユーザー | brthyyjp |
提出日時 | 2021-04-21 14:58:25 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,042 bytes |
コンパイル時間 | 319 ms |
コンパイル使用メモリ | 86,812 KB |
実行使用メモリ | 270,548 KB |
最終ジャッジ日時 | 2023-09-17 09:31:43 |
合計ジャッジ時間 | 11,790 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 72 ms
70,844 KB |
testcase_01 | AC | 77 ms
75,680 KB |
testcase_02 | AC | 88 ms
76,308 KB |
testcase_03 | AC | 81 ms
75,748 KB |
testcase_04 | AC | 78 ms
75,800 KB |
testcase_05 | AC | 72 ms
71,008 KB |
testcase_06 | AC | 88 ms
75,984 KB |
testcase_07 | AC | 79 ms
75,884 KB |
testcase_08 | AC | 85 ms
76,220 KB |
testcase_09 | AC | 160 ms
79,188 KB |
testcase_10 | AC | 131 ms
77,624 KB |
testcase_11 | AC | 127 ms
77,436 KB |
testcase_12 | AC | 807 ms
137,044 KB |
testcase_13 | TLE | - |
testcase_14 | AC | 576 ms
115,324 KB |
testcase_15 | AC | 460 ms
115,348 KB |
testcase_16 | AC | 614 ms
122,276 KB |
testcase_17 | AC | 690 ms
94,176 KB |
testcase_18 | AC | 72 ms
71,068 KB |
testcase_19 | AC | 73 ms
71,232 KB |
testcase_20 | AC | 73 ms
71,152 KB |
testcase_21 | AC | 131 ms
78,972 KB |
testcase_22 | AC | 106 ms
77,084 KB |
testcase_23 | AC | 116 ms
77,532 KB |
testcase_24 | TLE | - |
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 | -- | - |
ソースコード
import sys import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline def main(): n, k = map(int, input().split()) PD = [] for i in range(n): p, d = map(int, input().split()) PD.append((p,d)) PD.sort(key=lambda x: -x[0]) INF = 10**18 dp = [[-INF]*2 for i in range(k+1)] dp[0][0] = 0 for p, d in PD: nx = [[-INF]*2 for i in range(k+1)] for i in range(k+1): for j in range(2): nx[i][j] = max(nx[i][j], dp[i][j]) for i in range(k+1): for j in range(2): if dp[i][j] == -INF: continue if j == 0: if i+p <= k: nx[i+p][1] = max(nx[i+p][1], dp[i][j]+d) else: nx[i][0] = max(nx[i][0], dp[i][j]+d) dp = nx #print(dp) ans = -INF for i in range(k+1): for j in range(2): ans = max(ans, dp[i][j]) print(ans) if __name__ == '__main__': main()