結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,460 KB
testcase_01 AC 40 ms
53,460 KB
testcase_02 AC 39 ms
53,460 KB
testcase_03 AC 39 ms
53,460 KB
testcase_04 AC 39 ms
53,460 KB
testcase_05 AC 39 ms
53,460 KB
testcase_06 AC 40 ms
53,460 KB
testcase_07 AC 76 ms
72,600 KB
testcase_08 AC 79 ms
72,468 KB
testcase_09 AC 75 ms
72,476 KB
testcase_10 AC 71 ms
70,276 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 102 ms
76,016 KB
testcase_14 AC 109 ms
75,924 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 98 ms
75,888 KB
testcase_18 AC 105 ms
75,888 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 132 ms
94,064 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 441 ms
107,804 KB
testcase_29 WA -
testcase_30 AC 203 ms
118,912 KB
testcase_31 AC 402 ms
108,976 KB
testcase_32 AC 369 ms
110,688 KB
testcase_33 AC 116 ms
94,304 KB
testcase_34 AC 346 ms
109,744 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