結果

問題 No.1827 最長部分スーパーリッチ門松列列
ユーザー titiatitia
提出日時 2022-01-30 00:01:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,236 ms / 2,000 ms
コード長 653 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 10,976 KB
実行使用メモリ 66,416 KB
最終ジャッジ日時 2023-08-30 23:55:10
合計ジャッジ時間 25,391 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,416 KB
testcase_01 AC 16 ms
7,880 KB
testcase_02 AC 17 ms
8,004 KB
testcase_03 AC 92 ms
8,600 KB
testcase_04 AC 408 ms
8,524 KB
testcase_05 AC 411 ms
8,484 KB
testcase_06 AC 412 ms
8,544 KB
testcase_07 AC 1,043 ms
66,284 KB
testcase_08 AC 1,067 ms
66,388 KB
testcase_09 AC 1,059 ms
66,352 KB
testcase_10 AC 1,087 ms
66,304 KB
testcase_11 AC 1,062 ms
66,296 KB
testcase_12 AC 1,067 ms
66,348 KB
testcase_13 AC 1,056 ms
66,416 KB
testcase_14 AC 1,053 ms
66,292 KB
testcase_15 AC 1,063 ms
66,312 KB
testcase_16 AC 1,032 ms
66,268 KB
testcase_17 AC 1,205 ms
66,284 KB
testcase_18 AC 1,236 ms
66,300 KB
testcase_19 AC 1,060 ms
66,276 KB
testcase_20 AC 1,046 ms
66,352 KB
testcase_21 AC 1,060 ms
66,412 KB
testcase_22 AC 1,086 ms
66,304 KB
testcase_23 AC 1,087 ms
66,280 KB
testcase_24 AC 1,069 ms
66,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from operator import itemgetter

T=int(input())

for tests in range(T):
    N=int(input())
    P=list(map(int,input().split()))

    P_INV=[-1]*N

    for i in range(N):
        P_INV[P[i]-1]=i

    ANS=1
    A=[1]*N
    LANS=1

    for i in range(N):
        x=P_INV[i]

        now=0
        if x>0 and A[x-1]!=A[x]:
            now+=1
        if x<N-1 and A[x+1]!=A[x]:
            now+=1

        A[x]=0
        now2=0

        if x>0 and A[x-1]!=A[x]:
            now2+=1
        if x<N-1 and A[x+1]!=A[x]:
            now2+=1

        ANS+=now2-now
        LANS=max(LANS,ANS)

    print(LANS)

        

    
0