結果

問題 No.448 ゆきこーだーの雨と雪 (3)
ユーザー roarisroaris
提出日時 2019-12-15 22:24:17
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,073 bytes
コンパイル時間 373 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 846,144 KB
最終ジャッジ日時 2023-09-15 15:47:01
合計ジャッジ時間 5,142 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,244 KB
testcase_01 AC 71 ms
71,276 KB
testcase_02 AC 72 ms
71,312 KB
testcase_03 AC 71 ms
71,580 KB
testcase_04 AC 92 ms
76,536 KB
testcase_05 AC 99 ms
77,508 KB
testcase_06 AC 115 ms
84,092 KB
testcase_07 AC 93 ms
76,332 KB
testcase_08 AC 95 ms
76,672 KB
testcase_09 AC 103 ms
79,584 KB
testcase_10 AC 89 ms
76,172 KB
testcase_11 AC 104 ms
80,492 KB
testcase_12 AC 102 ms
80,104 KB
testcase_13 MLE -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def judge(x):
    T = [-10**18]+[Ti for Ti, Di in TD if Di>=D[x]]
    
    for i in range(len(T)-1):
        if T[i+1]-T[i]<K:
            return False
    
    return True

def binary_search():
    left, right = 0, len(D)-1
    
    while left<=right:
        mid = (left+right)//2
        
        if judge(mid):
            left = mid+1
        else:
            right = mid-1
    
    return right
            
N, K = map(int, input().split())
TD = [tuple(map(int, input().split())) for _ in range(N)]
D = list(set([Di for _, Di in TD]))
D.sort(reverse=True)
idx = binary_search()

if idx==len(D)-1:
    print(0)
else:
    print(D[idx+1])
    
dp = [[10**18]*(N+1) for _ in range(N+1)]
dp[0][0] = 0

for i in range(N):
    Ti, Di = TD[i]
    
    for j in range(i+1):
        if j==0:
            dp[i+1][i+1] = min(dp[i+1][i+1], dp[i][j])
        elif Ti-TD[j-1][0]>=K:
            dp[i+1][i+1] = min(dp[i+1][i+1], dp[i][j])
        
        if Di<D[idx]:
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]+Di)

print(min(dp[N]))
0