結果

問題 No.448 ゆきこーだーの雨と雪 (3)
ユーザー titiatitia
提出日時 2024-01-14 03:30:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 328 ms / 2,000 ms
コード長 934 bytes
コンパイル時間 242 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 146,184 KB
最終ジャッジ日時 2024-01-14 03:30:16
合計ジャッジ時間 10,301 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,460 KB
testcase_01 AC 34 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 34 ms
53,460 KB
testcase_04 AC 41 ms
59,580 KB
testcase_05 AC 44 ms
61,712 KB
testcase_06 AC 52 ms
64,284 KB
testcase_07 AC 42 ms
59,192 KB
testcase_08 AC 41 ms
59,452 KB
testcase_09 AC 45 ms
61,820 KB
testcase_10 AC 38 ms
53,460 KB
testcase_11 AC 47 ms
61,820 KB
testcase_12 AC 44 ms
61,820 KB
testcase_13 AC 113 ms
82,876 KB
testcase_14 AC 110 ms
83,616 KB
testcase_15 AC 158 ms
102,428 KB
testcase_16 AC 229 ms
122,932 KB
testcase_17 AC 217 ms
123,784 KB
testcase_18 AC 97 ms
81,376 KB
testcase_19 AC 315 ms
138,520 KB
testcase_20 AC 150 ms
97,836 KB
testcase_21 AC 278 ms
129,136 KB
testcase_22 AC 149 ms
98,104 KB
testcase_23 AC 278 ms
140,084 KB
testcase_24 AC 159 ms
89,220 KB
testcase_25 AC 291 ms
138,656 KB
testcase_26 AC 101 ms
81,488 KB
testcase_27 AC 228 ms
122,444 KB
testcase_28 AC 218 ms
118,016 KB
testcase_29 AC 154 ms
98,900 KB
testcase_30 AC 312 ms
145,128 KB
testcase_31 AC 103 ms
82,816 KB
testcase_32 AC 106 ms
83,740 KB
testcase_33 AC 321 ms
146,060 KB
testcase_34 AC 294 ms
145,924 KB
testcase_35 AC 328 ms
146,184 KB
testcase_36 AC 288 ms
145,792 KB
testcase_37 AC 313 ms
145,804 KB
testcase_38 AC 295 ms
145,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

from bisect import bisect_left,bisect

N,K=map(int,input().split())

TD=[list(map(int,input().split())) for i in range(N)]

SUM=0
LIST=[]
for t,d in TD:
    LIST.append(d)
    SUM+=d

LIST.append(0)
LIST.append(10**10)
LIST=sorted(set(LIST))

OK=len(LIST)-1
NG=0

while OK>NG+1:
    mid=(OK+NG)//2

    flag=0
    x=-1<<30

    for t,d in TD:
        if d>=LIST[mid]:
            if t-x<K:
                flag=1
                break
            else:
                x=t

    if flag==0:
        OK=mid
    else:
        NG=mid

DP=[(-2*10**9,0)]

for t,d in TD:
    #print(DP)
    x=bisect(DP,(t-K,10**10))-1
    #print(x)

    if d>LIST[OK-1]:
        a,b=DP[x]
        DP=[(-2000000000, 0),(t,d+b)]

    else:
        a,b=DP[x]
        DP.append((t,d+b))

    #print(DP)

    while len(DP)>=2 and DP[-1][1]<=DP[-2][1]:
        DP.pop()
    
        

print(LIST[OK-1])
print(SUM-DP[-1][1])
0