結果

問題 No.448 ゆきこーだーの雨と雪 (3)
ユーザー convexineqconvexineq
提出日時 2021-02-09 05:38:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 268 ms / 2,000 ms
コード長 814 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 86,968 KB
実行使用メモリ 84,400 KB
最終ジャッジ日時 2023-09-20 16:33:08
合計ジャッジ時間 9,942 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,360 KB
testcase_01 AC 71 ms
71,244 KB
testcase_02 AC 72 ms
71,368 KB
testcase_03 AC 72 ms
71,120 KB
testcase_04 AC 83 ms
75,648 KB
testcase_05 AC 85 ms
75,728 KB
testcase_06 AC 93 ms
76,260 KB
testcase_07 AC 85 ms
75,692 KB
testcase_08 AC 83 ms
75,704 KB
testcase_09 AC 87 ms
75,568 KB
testcase_10 AC 80 ms
75,592 KB
testcase_11 AC 88 ms
75,756 KB
testcase_12 AC 87 ms
75,716 KB
testcase_13 AC 136 ms
78,396 KB
testcase_14 AC 137 ms
78,828 KB
testcase_15 AC 171 ms
79,856 KB
testcase_16 AC 215 ms
82,036 KB
testcase_17 AC 203 ms
82,000 KB
testcase_18 AC 131 ms
78,460 KB
testcase_19 AC 248 ms
83,248 KB
testcase_20 AC 160 ms
79,924 KB
testcase_21 AC 248 ms
83,428 KB
testcase_22 AC 166 ms
79,844 KB
testcase_23 AC 247 ms
83,528 KB
testcase_24 AC 147 ms
79,108 KB
testcase_25 AC 248 ms
83,196 KB
testcase_26 AC 131 ms
78,404 KB
testcase_27 AC 218 ms
82,440 KB
testcase_28 AC 208 ms
81,632 KB
testcase_29 AC 169 ms
79,620 KB
testcase_30 AC 260 ms
83,820 KB
testcase_31 AC 134 ms
78,440 KB
testcase_32 AC 129 ms
78,788 KB
testcase_33 AC 268 ms
84,236 KB
testcase_34 AC 256 ms
84,400 KB
testcase_35 AC 268 ms
84,052 KB
testcase_36 AC 241 ms
84,160 KB
testcase_37 AC 265 ms
84,028 KB
testcase_38 AC 256 ms
84,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k = map(int,input().split())
t = [0]*n
d = [0]*n
for i in range(n):
    t[i],d[i] = map(int,input().split())

def check(x): #x以上を全部任せるが可能か?
    v = -1<<32
    for i in range(n):
        if d[i] >= x:
            if t[i]-v < k: return False
            else: v = t[i]
    return True

ok = 10**9+1
ng = 0
while ok-ng > 1:
    mid = (ok+ng)//2
    if check(mid): ok = mid
    else: ng = mid


acc = [0]*(n+1)
INF = 1<<40
for i in range(n):
    if d[i] >= ok: d[i] = INF
    acc[i+1] += acc[i]+d[i]

from bisect import bisect_left
dp2 = [0]*n #dp[i] = i 日目までの仕事の最小値
for i in range(n):
    ti,di = t[i],d[i]
    idx = bisect_left(t,ti-k+1)
    x = (dp2[idx-1] if idx else 0) + acc[i] - acc[idx] #休むとき
    dp2[i] = min(dp2[i-1]+di,x)

print(ok-1)
print(dp2[-1])
0