結果

問題 No.2650 [Cherry 6th Tune *] セイジャク
ユーザー titiatitia
提出日時 2024-02-23 22:14:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 534 ms / 2,500 ms
コード長 1,182 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 227,708 KB
最終ジャッジ日時 2024-02-23 22:14:58
合計ジャッジ時間 15,799 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 192 ms
110,556 KB
testcase_03 AC 144 ms
93,884 KB
testcase_04 AC 414 ms
184,104 KB
testcase_05 AC 318 ms
137,200 KB
testcase_06 AC 200 ms
116,584 KB
testcase_07 AC 338 ms
164,008 KB
testcase_08 AC 179 ms
102,856 KB
testcase_09 AC 503 ms
226,820 KB
testcase_10 AC 501 ms
226,976 KB
testcase_11 AC 529 ms
226,820 KB
testcase_12 AC 510 ms
226,972 KB
testcase_13 AC 534 ms
227,560 KB
testcase_14 AC 513 ms
227,556 KB
testcase_15 AC 533 ms
227,708 KB
testcase_16 AC 459 ms
226,824 KB
testcase_17 AC 488 ms
227,356 KB
testcase_18 AC 457 ms
227,556 KB
testcase_19 AC 459 ms
227,556 KB
testcase_20 AC 490 ms
226,968 KB
testcase_21 AC 463 ms
226,972 KB
testcase_22 AC 490 ms
227,556 KB
testcase_23 AC 452 ms
226,364 KB
testcase_24 AC 416 ms
226,232 KB
testcase_25 AC 447 ms
226,480 KB
testcase_26 AC 412 ms
226,500 KB
testcase_27 AC 422 ms
226,364 KB
testcase_28 AC 460 ms
226,400 KB
testcase_29 AC 424 ms
226,388 KB
testcase_30 AC 447 ms
226,920 KB
testcase_31 AC 436 ms
226,664 KB
testcase_32 AC 233 ms
122,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline


N,A=map(int,input().split())
X=list(map(int,input().split()))

T=int(input())
LR=[list(map(int,input().split())) for i in range(T)]

LIST=[]
for x in X:
    LIST.append(x)

for l,r in LR:
    LIST.append(l)
    LIST.append(r)

S=sorted(set(LIST))
D={S[i]:i for i in range(len(S))}


for i in range(N):
    X[i]=D[X[i]]

for i in range(T):
    LR[i][0]=D[LR[i][0]]
    LR[i][1]=D[LR[i][1]]

seg_el=1<<((max(X)+1).bit_length()) # Segment treeの台の要素数
SEG=[-1]*(2*seg_el) # 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化

def getvalue(n,seg_el): # 一点の値を取得
    i=n+seg_el
    ANS=-1
    
    ANS=max(SEG[i],ANS)
    i>>=1# 子ノードへ
    
    while i!=0:
        ANS=max(SEG[i],ANS)
        i>>=1

    return ANS

def updates(l,r,x): # 区間[l,r)のminを更新.
    L=l+seg_el
    R=r+seg_el

    while L<R:
        if L & 1:
            SEG[L]=max(x,SEG[L])
            L+=1

        if R & 1:
            R-=1
            SEG[R]=max(x,SEG[R])
        L>>=1
        R>>=1

for i in range(T):
    l,r=LR[i]

    updates(l,r+1,i+1)

for i in range(N):
    print(getvalue(X[i],seg_el))


0