結果

問題 No.1827 最長部分スーパーリッチ門松列列
ユーザー 👑 tamatotamato
提出日時 2022-01-28 22:15:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 414 ms / 2,000 ms
コード長 1,478 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 87,384 KB
実行使用メモリ 236,136 KB
最終ジャッジ日時 2023-08-28 20:17:31
合計ジャッジ時間 7,136 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,516 KB
testcase_01 AC 68 ms
71,288 KB
testcase_02 AC 68 ms
71,288 KB
testcase_03 AC 113 ms
78,200 KB
testcase_04 AC 116 ms
77,672 KB
testcase_05 AC 115 ms
77,228 KB
testcase_06 AC 113 ms
77,736 KB
testcase_07 AC 225 ms
223,740 KB
testcase_08 AC 225 ms
223,788 KB
testcase_09 AC 225 ms
223,568 KB
testcase_10 AC 226 ms
223,720 KB
testcase_11 AC 225 ms
223,732 KB
testcase_12 AC 223 ms
223,748 KB
testcase_13 AC 223 ms
223,764 KB
testcase_14 AC 223 ms
223,796 KB
testcase_15 AC 221 ms
223,828 KB
testcase_16 AC 223 ms
223,808 KB
testcase_17 AC 315 ms
235,840 KB
testcase_18 AC 414 ms
235,960 KB
testcase_19 AC 243 ms
223,848 KB
testcase_20 AC 244 ms
224,080 KB
testcase_21 AC 243 ms
223,940 KB
testcase_22 AC 267 ms
236,024 KB
testcase_23 AC 257 ms
235,904 KB
testcase_24 AC 258 ms
236,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.buffer.readline

    class Bit:
        def __init__(self, n):
            self.size = n
            self.tree = [0] * (n + 1)

        def sum(self, i):
            s = 0
            while i > 0:
                s += self.tree[i]
                i -= i & -i
            return s

        def add(self, i, x):
            while i <= self.size:
                self.tree[i] += x
                i += i & -i

        def lower_bound(self, w):
            if w <= 0:
                return 0
            x = 0
            k = 1 << (self.size.bit_length() - 1)
            while k:
                if x + k <= self.size and self.tree[x + k] < w:
                    w -= self.tree[x + k]
                    x += k
                k >>= 1
            return x + 1

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

        ans = 2

        idx = {p: i for i, p in enumerate(P)}
        add = 1
        cnt = 0
        for p in range(1, N+1):
            cnt += 1
            i = idx[p]
            if i == 0:
                add -= 1
            else:
                if P[i - 1] < p:
                    cnt -= 1
            if i == N - 1:
                add -= 1
            else:
                if P[i + 1] < p:
                    cnt -= 1
            ans = max(ans, cnt * 2 + add)
        print(ans)


if __name__ == '__main__':
    main()
0