結果

問題 No.2650 [Cherry 6th Tune *] セイジャク
ユーザー hiro1729hiro1729
提出日時 2024-02-23 21:45:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 979 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 92,432 KB
最終ジャッジ日時 2024-02-23 21:46:08
合計ジャッジ時間 9,718 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
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 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 298 ms
92,164 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left as bl
from bisect import bisect_right as br
N, A = map(int, input().split())
X = list(map(int, input().split()))

N0 = 2**(N-1).bit_length()
data = [None]*(2*N0)
INF = (-1, 2**31-1)
# 区間[l, r+1)の値をvに書き換える
# vは(t, value)という値にする (新しい値ほどtは大きくなる)
def update(l, r, v):
    L = l + N0; R = r + N0
    while L < R:
        if R & 1:
            R -= 1
            data[R-1] = v
 
        if L & 1:
            data[L-1] = v
            L += 1
        L >>= 1; R >>= 1
# a_iの現在の値を取得
def _query(k):
    k += N0-1
    s = INF
    while k >= 0:
        if data[k]:
            s = max(s, data[k])
        k = (k - 1) // 2
    return s
# これを呼び出す
def query(k):
    ans = _query(k)[1]
    return -1 if ans == 2147483647 else ans


for i in range(int(input())):
	L, R = map(int, input().split())
	update(bl(X, L), br(X, R), (i, i + 1))
for i in range(N):
	print(query(i))
0