結果

問題 No.992 最長増加部分列の数え上げ
ユーザー titiatitia
提出日時 2020-03-25 06:28:58
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,388 bytes
コンパイル時間 494 ms
コンパイル使用メモリ 87,248 KB
実行使用メモリ 176,540 KB
最終ジャッジ日時 2023-08-30 09:23:10
合計ジャッジ時間 30,739 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,264 KB
testcase_01 AC 69 ms
71,340 KB
testcase_02 AC 71 ms
71,436 KB
testcase_03 WA -
testcase_04 AC 478 ms
117,060 KB
testcase_05 AC 366 ms
106,800 KB
testcase_06 AC 506 ms
123,500 KB
testcase_07 AC 429 ms
112,172 KB
testcase_08 AC 275 ms
92,828 KB
testcase_09 AC 442 ms
112,252 KB
testcase_10 AC 541 ms
123,540 KB
testcase_11 AC 582 ms
116,484 KB
testcase_12 AC 215 ms
86,512 KB
testcase_13 AC 384 ms
111,780 KB
testcase_14 AC 412 ms
111,800 KB
testcase_15 AC 237 ms
87,308 KB
testcase_16 AC 953 ms
166,820 KB
testcase_17 AC 267 ms
93,192 KB
testcase_18 AC 407 ms
111,796 KB
testcase_19 AC 575 ms
116,380 KB
testcase_20 AC 925 ms
176,300 KB
testcase_21 WA -
testcase_22 AC 979 ms
176,384 KB
testcase_23 AC 931 ms
176,076 KB
testcase_24 AC 928 ms
176,084 KB
testcase_25 AC 1,008 ms
176,016 KB
testcase_26 AC 935 ms
175,988 KB
testcase_27 WA -
testcase_28 AC 993 ms
176,020 KB
testcase_29 AC 951 ms
176,284 KB
testcase_30 AC 514 ms
169,416 KB
testcase_31 AC 491 ms
169,108 KB
testcase_32 AC 515 ms
169,152 KB
testcase_33 AC 528 ms
168,856 KB
testcase_34 AC 510 ms
168,804 KB
testcase_35 AC 526 ms
167,432 KB
testcase_36 AC 537 ms
167,704 KB
testcase_37 AC 527 ms
167,552 KB
testcase_38 AC 542 ms
167,576 KB
testcase_39 AC 531 ms
167,452 KB
testcase_40 AC 503 ms
169,136 KB
testcase_41 AC 493 ms
168,752 KB
testcase_42 AC 504 ms
169,448 KB
testcase_43 AC 521 ms
168,972 KB
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A=list(map(int,input().split()))
mod=10**9+7

compression_dict={a: ind+1 for ind, a in enumerate(sorted(set(A)))}
A=[compression_dict[a] for a in A]

def seg_function(x,y): # Segment treeで扱うfunction
    if x[0]==y[0]:
        return (x[0],x[1]+y[1])
    elif x[0]>y[0]:
        return x
    else:
        return y

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

def update(n,x,seg_el): # A[n]をxへ更新(反映)
    i=n+seg_el
    SEG[i]=x
    i>>=1# 子ノードへ
    
    while i!=0:
        SEG[i]=seg_function(SEG[i*2],SEG[i*2+1])
        i>>=1
        
def getvalues(l,r):# 区間[l,r)に関するseg_functionを調べる
    L=l+seg_el
    R=r+seg_el
    ANS=(-1,0)

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

        if R & 1:
            R-=1
            ANS=seg_function(ANS , SEG[R])
        L>>=1
        R>>=1

    return ANS

update(0,(0,1),seg_el)

for a in A:
    x=getvalues(0,a+1)
    y=getvalues(a,a+1)
    z=getvalues(0,a)

    #print(a,x,y)

    if x[0]==y[0]:
        update(a,(x[0],z[1]+y[1]),seg_el)
    else:
        update(a,(x[0]+1,x[1]+y[1]),seg_el)

    #for i in range(6):
    #    print(getvalues(i,i+1),end=" ")
    #print()
    
print(getvalues(0,N+1)[1]%mod)
0