結果

問題 No.951 【本日限定】1枚頼むともう1枚無料!
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-11-10 09:41:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 705 ms / 2,000 ms
コード長 640 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 78,196 KB
最終ジャッジ日時 2023-11-10 09:41:50
合計ジャッジ時間 16,335 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
55,604 KB
testcase_01 AC 45 ms
57,704 KB
testcase_02 AC 58 ms
68,084 KB
testcase_03 AC 49 ms
63,884 KB
testcase_04 AC 47 ms
57,704 KB
testcase_05 AC 42 ms
55,604 KB
testcase_06 AC 56 ms
66,012 KB
testcase_07 AC 44 ms
57,704 KB
testcase_08 AC 54 ms
66,012 KB
testcase_09 AC 81 ms
74,420 KB
testcase_10 AC 73 ms
72,884 KB
testcase_11 AC 72 ms
72,876 KB
testcase_12 AC 158 ms
76,988 KB
testcase_13 AC 347 ms
77,940 KB
testcase_14 AC 125 ms
76,716 KB
testcase_15 AC 119 ms
76,580 KB
testcase_16 AC 137 ms
76,968 KB
testcase_17 AC 196 ms
77,172 KB
testcase_18 AC 45 ms
57,704 KB
testcase_19 AC 49 ms
57,704 KB
testcase_20 AC 44 ms
57,704 KB
testcase_21 AC 70 ms
72,756 KB
testcase_22 AC 69 ms
72,628 KB
testcase_23 AC 69 ms
72,628 KB
testcase_24 AC 411 ms
78,068 KB
testcase_25 AC 444 ms
78,068 KB
testcase_26 AC 466 ms
77,428 KB
testcase_27 AC 485 ms
78,196 KB
testcase_28 AC 366 ms
77,300 KB
testcase_29 AC 405 ms
77,556 KB
testcase_30 AC 45 ms
55,604 KB
testcase_31 AC 43 ms
55,604 KB
testcase_32 AC 71 ms
72,500 KB
testcase_33 AC 75 ms
74,544 KB
testcase_34 AC 82 ms
76,464 KB
testcase_35 AC 683 ms
78,068 KB
testcase_36 AC 656 ms
78,196 KB
testcase_37 AC 705 ms
77,556 KB
testcase_38 AC 490 ms
77,940 KB
testcase_39 AC 494 ms
77,940 KB
testcase_40 AC 503 ms
77,556 KB
testcase_41 AC 535 ms
77,556 KB
testcase_42 AC 495 ms
77,940 KB
testcase_43 AC 494 ms
77,556 KB
testcase_44 AC 511 ms
77,556 KB
testcase_45 AC 488 ms
77,940 KB
testcase_46 AC 376 ms
77,172 KB
testcase_47 AC 358 ms
77,172 KB
testcase_48 AC 367 ms
77,428 KB
testcase_49 AC 347 ms
77,172 KB
testcase_50 AC 432 ms
77,556 KB
testcase_51 AC 366 ms
77,428 KB
testcase_52 AC 268 ms
77,044 KB
testcase_53 AC 301 ms
77,044 KB
testcase_54 AC 208 ms
77,428 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(2)]
dp[0][0] = 0

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