結果

問題 No.2698 Many Asakatsu
ユーザー 👑 rin204rin204
提出日時 2024-03-22 22:24:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,092 bytes
コンパイル時間 598 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 123,136 KB
最終ジャッジ日時 2024-03-22 22:24:23
合計ジャッジ時間 8,290 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 38 ms
53,460 KB
testcase_04 AC 38 ms
53,460 KB
testcase_05 AC 38 ms
53,460 KB
testcase_06 AC 37 ms
53,460 KB
testcase_07 AC 76 ms
72,600 KB
testcase_08 AC 78 ms
72,468 KB
testcase_09 AC 72 ms
72,476 KB
testcase_10 AC 68 ms
70,276 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 96 ms
76,016 KB
testcase_14 AC 103 ms
75,932 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 94 ms
75,888 KB
testcase_18 AC 100 ms
76,016 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 127 ms
94,136 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 406 ms
107,772 KB
testcase_29 WA -
testcase_30 AC 189 ms
118,912 KB
testcase_31 AC 407 ms
108,972 KB
testcase_32 AC 372 ms
110,688 KB
testcase_33 AC 118 ms
94,304 KB
testcase_34 AC 357 ms
109,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
A = [0] * n
B = [0] * n
for i in range(n):
    A[i], B[i] = map(int, input().split())

Q, x = map(int, input().split())
C = list(map(int, input().split()))


def f(i, x):
    a, b = A[i], B[i]
    x -= a
    if b == 0:
        return abs(x) * m
    p = x // b
    if p < 0:
        return m * (b * (m - 1)) // 2 - x * m
    elif p >= m:
        return x * m - m * (b * (m - 1)) // 2
    else:
        ret = x * (p + 1) - (p + 1) * (b * p) // 2
        ret += (m - 1 - p) * (b * (p + 1) + b * (m - 1)) // 2 - x * (m - 1 - p)
        return ret


P = [0]
thr = []
i = 1
while i < n:
    bi = P[-1]
    l = A[bi]
    r = A[i] + B[i] * (m - 1)

    while r - l > 1:
        mid = (l + r) // 2
        if f(bi, mid) > f(i, mid):
            r = mid
        else:
            l = mid

    if not thr or thr[-1] <= r:
        P.append(i)
        thr.append(r)
        i += 1
    else:
        P.pop()
        thr.pop()

p = 0
ans = []

for _ in range(Q):
    while p < len(P) - 1 and x >= thr[p]:
        p += 1
    ans.append(P[p] + 1)
    x += C[P[p]]
print(*ans)
0