結果

問題 No.951 【本日限定】1枚頼むともう1枚無料!
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-11-10 09:38:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,956 ms / 2,000 ms
コード長 805 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 471,248 KB
最終ジャッジ日時 2023-11-10 09:39:54
合計ジャッジ時間 53,057 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
55,732 KB
testcase_01 AC 54 ms
63,796 KB
testcase_02 AC 70 ms
70,324 KB
testcase_03 AC 59 ms
66,160 KB
testcase_04 AC 54 ms
63,796 KB
testcase_05 AC 48 ms
57,832 KB
testcase_06 AC 67 ms
70,328 KB
testcase_07 AC 52 ms
63,792 KB
testcase_08 AC 63 ms
68,236 KB
testcase_09 AC 143 ms
86,456 KB
testcase_10 AC 124 ms
81,944 KB
testcase_11 AC 120 ms
82,164 KB
testcase_12 AC 427 ms
154,448 KB
testcase_13 AC 1,258 ms
352,592 KB
testcase_14 AC 289 ms
121,916 KB
testcase_15 AC 307 ms
124,860 KB
testcase_16 AC 436 ms
149,584 KB
testcase_17 AC 492 ms
166,804 KB
testcase_18 AC 49 ms
57,832 KB
testcase_19 AC 49 ms
57,832 KB
testcase_20 AC 49 ms
57,832 KB
testcase_21 AC 108 ms
81,436 KB
testcase_22 AC 102 ms
78,144 KB
testcase_23 AC 100 ms
79,260 KB
testcase_24 AC 1,956 ms
471,248 KB
testcase_25 AC 1,804 ms
470,864 KB
testcase_26 AC 1,808 ms
470,352 KB
testcase_27 AC 1,860 ms
470,992 KB
testcase_28 AC 1,789 ms
470,224 KB
testcase_29 AC 1,781 ms
470,736 KB
testcase_30 AC 50 ms
57,832 KB
testcase_31 AC 48 ms
57,832 KB
testcase_32 AC 104 ms
78,572 KB
testcase_33 AC 122 ms
80,628 KB
testcase_34 AC 123 ms
84,568 KB
testcase_35 AC 1,459 ms
470,736 KB
testcase_36 AC 1,499 ms
471,248 KB
testcase_37 AC 1,452 ms
470,864 KB
testcase_38 AC 1,888 ms
471,248 KB
testcase_39 AC 1,850 ms
471,248 KB
testcase_40 AC 1,577 ms
470,992 KB
testcase_41 AC 1,865 ms
470,992 KB
testcase_42 AC 1,894 ms
471,248 KB
testcase_43 AC 1,863 ms
470,992 KB
testcase_44 AC 1,867 ms
470,992 KB
testcase_45 AC 1,862 ms
471,248 KB
testcase_46 AC 1,803 ms
470,224 KB
testcase_47 AC 1,774 ms
470,224 KB
testcase_48 AC 1,755 ms
470,608 KB
testcase_49 AC 1,766 ms
470,224 KB
testcase_50 AC 1,599 ms
470,992 KB
testcase_51 AC 1,758 ms
470,608 KB
testcase_52 AC 1,231 ms
393,424 KB
testcase_53 AC 1,484 ms
470,480 KB
testcase_54 AC 1,775 ms
470,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

N,K = map(int,input().split())
PD = [tuple(map(int,input().split())) for _ in range(N)]
PD.sort(reverse=True)

INF = (1<<60)

dp = [[[-INF]*(K+2) for i in range(N+1)] for j in range(2)]
dp[0][0][0] = 0

for i in range(N):
    
    p,d = PD[i]
    
    for k in range(2):
        
        for j in range(K+1):
            
            dp[k][i+1][j] = dp[k][i][j]
    
    
    for j in range(K+1):
        
        
        dp[0][i+1][min(j+p,K+1)] = max(dp[0][i][min(j+p,K+1)],dp[1][i][min(j+p,K+1)]+d)
        
        dp[1][i+1][min(j+p,K+1)] = max(dp[1][i][min(j+p,K+1)],dp[0][i][j] + d)
        
        
    
print(max(max(dp[0][-1][:K+1]),max(dp[1][-1][:K+1])))
0