結果

問題 No.448 ゆきこーだーの雨と雪 (3)
ユーザー H3PO4H3PO4
提出日時 2023-07-16 09:11:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,336 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 11,884 KB
実行使用メモリ 58,644 KB
最終ジャッジ日時 2023-10-17 14:53:09
合計ジャッジ時間 16,808 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,148 KB
testcase_01 AC 29 ms
10,148 KB
testcase_02 AC 30 ms
10,148 KB
testcase_03 AC 30 ms
10,148 KB
testcase_04 AC 31 ms
10,204 KB
testcase_05 AC 32 ms
10,216 KB
testcase_06 AC 34 ms
10,316 KB
testcase_07 AC 31 ms
10,204 KB
testcase_08 AC 32 ms
10,200 KB
testcase_09 AC 32 ms
10,240 KB
testcase_10 AC 31 ms
10,176 KB
testcase_11 AC 32 ms
10,256 KB
testcase_12 AC 33 ms
10,240 KB
testcase_13 WA -
testcase_14 AC 153 ms
17,396 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 113 ms
14,908 KB
testcase_27 WA -
testcase_28 AC 554 ms
40,296 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 146 ms
17,380 KB
testcase_33 WA -
testcase_34 AC 851 ms
58,576 KB
testcase_35 WA -
testcase_36 AC 811 ms
58,576 KB
testcase_37 WA -
testcase_38 AC 850 ms
58,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# https://yukicoder.me/problems/no/448

from bisect import bisect_left

N, K = map(int, input().split())
queries = []
for _ in range(N):
    queries.append(tuple(map(int, input().split())))


def isOK(x):
    wake = None
    for t, d in queries:
        if d > x:
            if (wake is not None) and t - wake < K:
                return False
            wake = t
    return True


# 難しさの最大値の最小化
def calc_min_diff():
    l, r = -1, 10 ** 9 + 5
    while (r - l) > 1:
        m = (r + l) // 2
        if isOK(m):
            r = m
        else:
            l = m
    return r


# 難しさの総和の最小化
def calc_min_sum(max_diff: int):
    INF = 10 ** 9

    acc = [0] * (N + 1)
    for i, (_, d) in enumerate(queries):
        acc[i + 1] = acc[i] + (d if d <= max_diff else INF)  # ame連続でやる.不可能ならINF

    dp = [0] * (N + 1)
    yuki_idx = 0
    for i, (t, d) in enumerate(queries):
        while queries[yuki_idx][0] < t - K + 1:
            yuki_idx += 1
        dp[i + 1] = min(
            dp[i] + (d if d <= max_diff else INF),  # ameがやる
            dp[yuki_idx] + acc[i] - acc[yuki_idx]  # yukiがやる
        )
        # print(i, yuki_idx, dp[i + 1])
    return dp[-1]


max_diff = calc_min_diff()
print(max_diff)
total_diff = calc_min_sum(max_diff)
print(total_diff)
0