結果

問題 No.2650 [Cherry 6th Tune *] セイジャク
ユーザー Ekiben542Ekiben542
提出日時 2024-03-03 21:59:01
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,083 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 91,748 KB
最終ジャッジ日時 2024-03-03 21:59:06
合計ジャッジ時間 5,463 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
60,264 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

class SegmentTree:
    def __init__(self, size):
        self.size = 2**(size - 1).bit_length()
        self.data = [-1]*(2*self.size)

    def update(self, k, x):
        k += self.size
        self.data[k] = x
        while k > 0:
            k >>= 1
            self.data[k] = max(self.data[k*2], self.data[k*2+1])

    def query(self, l, r):
        L = l + self.size
        R = r + self.size
        s = -1
        while L < R:
            if R & 1:
                R -= 1
                s = max(s, self.data[R])
            if L & 1:
                s = max(s, self.data[L])
                L += 1
            L >>= 1
            R >>= 1
        return s
import bisect
N, A = map(int, input().split())
X = sorted(list(map(int, input().split())))
T = int(input())
LR = [list(map(int, input().split())) for _ in range(T)]

seg_tree = SegmentTree(N)

for t in range(T):
    L, R = LR[t]
    start = bisect.bisect_left(X, L)
    end = bisect.bisect_right(X, R)
    for i in range(start, end):
        seg_tree.update(i, t+1)

for i in range(N):
    print(seg_tree.query(i, i+1))
0