結果

問題 No.1827 最長部分スーパーリッチ門松列列
ユーザー first_vilfirst_vil
提出日時 2022-01-28 22:44:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 232 ms / 2,000 ms
コード長 1,042 bytes
コンパイル時間 1,007 ms
コンパイル使用メモリ 86,912 KB
実行使用メモリ 162,136 KB
最終ジャッジ日時 2023-08-28 21:14:50
合計ジャッジ時間 7,216 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,044 KB
testcase_01 AC 73 ms
71,344 KB
testcase_02 AC 74 ms
71,340 KB
testcase_03 AC 142 ms
77,900 KB
testcase_04 AC 131 ms
77,364 KB
testcase_05 AC 131 ms
77,308 KB
testcase_06 AC 130 ms
77,408 KB
testcase_07 AC 196 ms
161,952 KB
testcase_08 AC 193 ms
161,924 KB
testcase_09 AC 187 ms
161,772 KB
testcase_10 AC 191 ms
162,048 KB
testcase_11 AC 193 ms
161,776 KB
testcase_12 AC 192 ms
161,988 KB
testcase_13 AC 186 ms
161,812 KB
testcase_14 AC 189 ms
162,060 KB
testcase_15 AC 187 ms
161,960 KB
testcase_16 AC 192 ms
161,908 KB
testcase_17 AC 232 ms
162,132 KB
testcase_18 AC 231 ms
161,948 KB
testcase_19 AC 210 ms
162,136 KB
testcase_20 AC 208 ms
161,888 KB
testcase_21 AC 204 ms
161,916 KB
testcase_22 AC 201 ms
161,724 KB
testcase_23 AC 205 ms
162,004 KB
testcase_24 AC 207 ms
161,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

int1 = lambda x: int(x) - 1

# input = lambda: sys.stdin.buffer.readline()
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
i1 = lambda: int1(input())
mi = lambda: map(int, input().split())
mi1 = lambda: map(int1, input().split())
li = lambda: list(mi())
li1 = lambda: list(mi1())
lli = lambda n: [li() for _ in range(n)]

INF = float("inf")
mod = int(1e9 + 7)
# mod = 998244353

for _ in range(ii()):
    n = ii()
    p = li1()
    q = [-1] * n
    for i in range(n):
        q[p[i]] = i
    ans = 0
    cur = 1
    same = [True] * (n - 1)
    c = [0] * n
    for i, j in enumerate(q):
        if 0 <= j - 1 and same[j - 1]:
            cur += 1
        if j < n - 1 and same[j]:
            cur += 1
        c[j] = 1
        if 0 <= j - 1:
            same[j - 1] = c[j - 1] == c[j]
            if same[j - 1]:
                cur -= 1
        if j < n - 1:
            same[j] = c[j] == c[j + 1]
            if same[j]:
                cur -= 1
        if ans < cur:
            ans = cur
    print(ans)
0